美文网首页
iOS打印正宗的JSON

iOS打印正宗的JSON

作者: dxin_101 | 来源:发表于2021-05-28 10:26 被阅读0次

- (void)fb_descriptionJson:(NSDictionary*)dicM callBack:(void(^)(NSString* logMessage))callBack{

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        NSString*logString;

        @try{

            logString=[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:dicM options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding];

            callBack ? callBack(logString) :nil;

        }@catch(NSException *exception) {

            NSString*reason = [NSString stringWithFormat:@"reason:%@",exception.reason];

            logString = [NSString stringWithFormat:@"转换失败:\n%@,\n转换终止,输出如下:\n%@",reason,self.description];

        }@finally{

        }

    });

}

相关文章

网友评论

      本文标题:iOS打印正宗的JSON

      本文链接:https://www.haomeiwen.com/subject/xwtssltx.html