【问题标题】:Convert Array to JSON file将数组转换为 JSON 文件
【发布时间】:2013-03-03 17:20:42
【问题描述】:

我使用 JSONKit 将 .json 文件中的数据转换为 NSMutableArray。 如何将 Array 转换回 JSON 数据并将其写入文件? 可以使用其他一些套件吗?

【问题讨论】:

    标签: xcode arrays json


    【解决方案1】:

    您可以为此使用SBJsonWriter 类:

    SBJsonWriter *writer = [SBJsonWriter new];
    NSString *jsonString = [writer stringWithObject:yourArray];
    

    您可以从 Converting NSArray -> JSON -> NSData -> PHP server ->JSON representation

    SBJsonWriter Nested NSDictionary

    【讨论】:

    • 如果我想制作“arrayWithObject”怎么办?以及如何将其写入现有文件: NSString *path = [[NSBundle mainBundle] pathForResource:@"try" ofType:@"json"];
    猜你喜欢
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多