-1

我在存储我正在下载的一些 json 数据时遇到问题。我认为的问题是从字符串到 json 再到 const char 的转换。也可能有更好的方法来做到这一点。这就是我所拥有的

 NSDictionary *jsonAll = [[(NSString *)response uppercaseString] JSONValue];
//Get the objects within the seat number object


NSDictionary *seatInfo = [jsonAll objectForKey:seatMessage];

//Split the objects up accoridng to the track information -- we will have to structure  
//we havethe maeesge with how ever many track

NSMutableString *Track1 = [seatInfo objectForKey:@"TRACK1'];
NSMutableString *Track2 = [seatInfo objectForKey:@"TRACK2"];

我带来的 json 文件看起来像这样

{A1 =     {
    TRACK1 =         (
        1462527,
        1462527,
        1462527,
        1462527,
        1462527,
        1462527,
        1462527,
        1462527,
        1462527,
        1462527,
        1462527
    );
    TRACK2 =         (
        12800016,
        12800016,
        12800016,
        12800016,
        12800016,
        1462527,
        12800016,
        12800016,
        12800016,
        12800016,
        12800016
    );
};

}

我认为问题在于新线路。据我所知,当我尝试将数据存储在 sql 中时,我必须将其转换为 const char。

有人知道怎么做吗?

谢谢

4

1 回答 1

0
 NSDictionary *jsonAll = [[(NSString *)response uppercaseString] JSONValue];

//获取座位号对象内的对象

NSDictionary *seatInfo = [jsonAll objectForKey:seatMessage];

//根据轨道信息拆分对象——我们必须构造
//我们有多少轨道的maeesge

NSArray *Track1 = [seatInfo objectForKey:@"TRACK1'];

for(id str in Track1)
{
   //save the strings in database   
}
于 2012-09-03T19:05:54.857 回答