JSON 正在解析 Objective-c[xcode 6]
JSON Parsing in Objective-c[xcode 6]
我收到这样的回复。我怎样才能得到这些值?
MODEOFTRAVEL_ID
这是键值,MODEOFTRAVELNAME
这是另一个键。
{
ColumnValuesList = (
(
1,
Flight
),
(
2,
Train
),
(
3,
"By Road"
),
(
21,
"By Bus"
)
);
TableColumns = (
"MODEOFTRAVEL_ID",
MODEOFTRAVELNAME
);
TableName = "CTZ_MODEOFTRAVEL";
},
如果问题数据是 NSDictionary
变量(比如 d)的内容,则:
示例:
NSDictionary *d = @{
@"ColumnValuesList" : @[
@[ @1, @"Flight" ],
@[ @2, @"Train" ],
@[ @3, @"By Road" ],
@[ @21, @"By Bus" ]
],
@"TableColumns" : @[
@"MODEOFTRAVEL_ID",
@"MODEOFTRAVELNAME"
],
@"TableName" : @"CTZ_MODEOFTRAVEL"
};
NSString *columnName0 = d[@"TableColumns"][0];
NSString *columnName1 = d[@"TableColumns"][1];
NSLog(@"columnName0: %@", columnName0);
NSLog(@"columnName1: %@", columnName1);
输出:
columnName0: MODEOFTRAVEL_ID
columnName1: MODEOFTRAVELNAME
我收到这样的回复。我怎样才能得到这些值?
MODEOFTRAVEL_ID
这是键值,MODEOFTRAVELNAME
这是另一个键。
{
ColumnValuesList = (
(
1,
Flight
),
(
2,
Train
),
(
3,
"By Road"
),
(
21,
"By Bus"
)
);
TableColumns = (
"MODEOFTRAVEL_ID",
MODEOFTRAVELNAME
);
TableName = "CTZ_MODEOFTRAVEL";
},
如果问题数据是 NSDictionary
变量(比如 d)的内容,则:
示例:
NSDictionary *d = @{
@"ColumnValuesList" : @[
@[ @1, @"Flight" ],
@[ @2, @"Train" ],
@[ @3, @"By Road" ],
@[ @21, @"By Bus" ]
],
@"TableColumns" : @[
@"MODEOFTRAVEL_ID",
@"MODEOFTRAVELNAME"
],
@"TableName" : @"CTZ_MODEOFTRAVEL"
};
NSString *columnName0 = d[@"TableColumns"][0];
NSString *columnName1 = d[@"TableColumns"][1];
NSLog(@"columnName0: %@", columnName0);
NSLog(@"columnName1: %@", columnName1);
输出:
columnName0: MODEOFTRAVEL_ID
columnName1: MODEOFTRAVELNAME