Json字符串与字典互转
#pragma mark 转换json字符串
+(NSString *)toJSON:(id)aParam
{
NSData *jsonData=[NSJSONSerialization dataWithJSONObject:aParam options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonStr=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
return jsonStr;
}
#pragma mark 字符串转字典
+(NSDictionary *)dicWithJSonStr:(NSString *)jsonString
{
NSData * jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
return dic;
}