我正面臨一些可憐的問題。我在這裏分享我的代碼和響應..JSON響應在NSArray中轉換後顯示空白值
JSON響應:
JSON登錄:
[
{
"0": "41",
"intid": "41",
"1": "\u8a00\u3046",
"varfirstname": "\u8a00\u3046",
"2": "test",
"varlastname": "test",
"3": "\u5730",
"varusername": "\u5730",
"4": "[email protected]",
"varemailid": "[email protected]",
"5": "qwert",
"varpassword": "qwert",
"6": "12345",
"varmobileno": "12345",
"7": "Enable",
"mobileMessage": "Enable",
"8": "",
"varphoneno": "",
"9": "Enable",
"enumstatus": "Enable",
"10": "2013-01-30",
"date_insert": "2013-01-30",
"11": "2013-01-30",
"date_edit": "2013-01-30",
"12": "210.211.252.1",
"varipaddress": "210.211.252.1"
}
]
從這種反應,我喜歡這個轉換的NSArray ..
// Create new SBJSON parser object
SBJSON *parser = [[SBJSON alloc] init];
NSArray *array = (NSArray *) [parser objectWithString:json_string error:nil];
NSLog(@"Array === %@",array);
And This Array顯示此數據:
日誌:
Array ===
(
{
0 = 41;
1 = "";
10 = "2013-01-30";
11 = "2013-01-30";
12 = "210.211.252.1";
2 = test;
3 = "";
4 = "[email protected]";
5 = qwert;
6 = 12345;
7 = Enable;
8 = "";
9 = Enable;
"date_edit" = "2013-01-30";
"date_insert" = "2013-01-30";
enumstatus = Enable;
intid = 41;
mobileMessage = Enable;
varemailid = "[email protected]";
varfirstname = "";
varipaddress = "210.211.252.1";
varlastname = test;
varmobileno = 12345;
varpassword = qwert;
varphoneno = "";
varusername = "";
})
而且我轉換我的VarfirstName像這樣
NSDictionary *dataObject=[array objectAtIndex:0];
NSString *status = [dataObject objectForKey:@"varfirstname"];
NSLog(@"status -- %@",status);
NSString *myDecodedS = status;
NSString *myDecoded = [myDecodedS stringByReplacingPercentEscapesUsingEncoding:NSUTF16StringEncoding];
NSLog(@"HIIii %@",myDecoded);
任何一個可以告訴我,我如何能得到的數據從那個JSON響應...... 我不是得到我做錯了什麼?
你正在獲得數組。但你是否得到dataObject?記錄字典。 –
它來自同一個人..沒有區別在那... – Vivek2012
什麼是空白? varfirstname? – rdelmar