JLChen
2021-05-18 a869383e163a18cdedcf587383c1eca043129754
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
//  NSObject+LCOpenSDK.m
//  LCOpenSDKDemo
//
//  Created by bzy on 17/3/21.
//  Copyright © 2017年 lechange. All rights reserved.
//
 
#import "NSDictionary+LCOpenSDK.h"
 
@implementation NSDictionary(LCOpenSDK)
 
/**
 Ch:将所有属性值序列化为JSON字符串
 En:Serialize all attribute values into JSON strings
 */
- (NSString*)toJSONString
{
    NSString *jsonStr;
    NSArray *keys = [self allKeys];
    for (NSString* key in keys) {
        NSString* value = [self objectForKey:key];
        if (!jsonStr) {
            jsonStr = [NSString stringWithFormat:@"\"%@\":\"%@\"",key,value];
        } else {
            jsonStr = [jsonStr stringByAppendingFormat:@",\"%@\":\"%@\"",key,value];
        }
    }
    jsonStr = [NSString stringWithFormat:@"\"params\":{%@}", jsonStr];
    return jsonStr;
}
@end