代码之家  ›  专栏  ›  技术社区  ›  Matt S.

使用Objective-C生成JSON字符串

  •  1
  • Matt S.  · 技术社区  · 15 年前

    3 回复  |  直到 12 年前
        1
  •  3
  •   Jacob Relkin    15 年前

    我个人喜欢 json-framework 在上使用类别 NSObject 因为必须经历 TouchJSON CJSONDataSerializer 接口。

    NSDictionary *dict = [NSDictionary dictionaryWithObject:@"b" forKey:@"a"];
    NSString *json = [dict JSONRepresentation];
    
        2
  •  0
  •   Kendall Helmstetter Gelner    15 年前

    TouchJSON包含一种获取字典并从中生成JSON的机制:

    http://github.com/schwa/TouchJSON

    NSDictionary *dictionary = [NSDictionary dictionaryWithObject:@"b" forKey:@"a"];
    NSError *error = NULL;
    NSData *jsonData = [[CJSONDataSerializer serializer] serializeObject:dictionary error&error];
    
        3
  •  0
  •   imaginaryboy    15 年前