0
之後的字符串問題我試圖從服務器上下載JSON字符串,這看起來不應該如此。 對不起,格式化,使用計算器第一次..NSUTF8StringEncoding
正如你可以從接收到的字符串進行比較,並從PHP, 關鍵的從arr[LISTING][<this ones>]
被移除的var_dump ..等我進一步的JSON解碼並把看從arr[LISTING][<this one>]
作爲一個值輸入,而不是另一個數組子維
任何想法?
我的嘗試:
NSData *serverRes = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *serverRes_str=[[NSString alloc]initWithData:serverRes encoding:NSUTF8StringEncoding];
NSLog(@"%@",serverRes_str);
這是什麼樣子:
{"STATUS":{"RESULT":"OK","CODE":205,"INFO":"GET_PROJECTS","AUTHENTICATED":1,"USERID":1,"ACCESS":1000,"SYSTEM_NAME":"Testdatei","SSL":false,"IDENTIFIER":""},"CONTENT":{"GET_PROJECTS":{"COUNT":7,"LISTING":[{"ID":"1","NAME":"Devel","CREATION_DATE":"1357116685","CREATED_BY":"admin","TYPE":"PROJECT","PUBLIC":false,"PRIVAT":false,"ACCESS":3,"THUMBNAIL":""},{"ID":"30","NAME":"p5","CREATION_DATE":"1365866791","CREATED_BY":"admin","TYPE":"PROJECT","PUBLIC":false,"PRIVAT":false,"ACCESS":3,"THUMBNAIL":""},{"ID":"29","NAME":"p4","CREATION_DATE":"1365866785","CREATED_BY":"admin","TYPE":"PROJECT","PUBLIC":false,"PRIVAT":false,"ACCESS":3,"THUMBNAIL":""},{"ID":"28","NAME":"p3","CREATION_DATE":"1365866780","CREATED_BY":"admin","TYPE":"PROJECT","PUBLIC":false,"PRIVAT":false,"ACCESS":3,"THUMBNAIL":""},{"ID":"27","NAME":"p2","CREATION_DATE":"1365866773","CREATED_BY":"admin","TYPE":"PROJECT","PUBLIC":false,"PRIVAT":false,"ACCESS":3,"THUMBNAIL":""},{"ID":"26","NAME":"p1","CREATION_DATE":"1365866767","CREATED_BY":"admin","TYPE":"PROJECT","PUBLIC":false,"PRIVAT":false,"ACCESS":3,"THUMBNAIL":""},{"ID":"4","NAME":"Testimmortals","CREATION_DATE":"1362388820","CREATED_BY":"admin","TYPE":"PROJECT","PUBLIC":false,"PRIVAT":false,"ACCESS":3,"THUMBNAIL":""}]}}}
它應該是什麼樣子:
array(2) {
["COUNT"]=>
int(7)
["LISTING"]=>
array(7) {
[0]=>
array(9) {
["ID"]=>
string(1) "1"
["NAME"]=>
string(5) "Devel"
["CREATION_DATE"]=>
string(10) "1357116685"
["CREATED_BY"]=>
string(5) "admin"
["TYPE"]=>
string(7) "PROJECT"
["PUBLIC"]=>
bool(false)
["PRIVAT"]=>
bool(false)
["ACCESS"]=>
int(3)
["THUMBNAIL"]=>
string(92) ""
}
[1]=>
array(9) {
["ID"]=>
string(2) "30"
["NAME"]=>
string(2) "p5"
["CREATION_DATE"]=>
string(10) "1365866791"
["CREATED_BY"]=>
string(5) "admin"
["TYPE"]=>
string(7) "PROJECT"
["PUBLIC"]=>
bool(false)
["PRIVAT"]=>
bool(false)
["ACCESS"]=>
int(3)
["THUMBNAIL"]=>
string(93) ""
}
[2]=>
array(9) {
["ID"]=>
string(2) "29"
["NAME"]=>
string(2) "p4"
["CREATION_DATE"]=>
string(10) "1365866785"
["CREATED_BY"]=>
string(5) "admin"
["TYPE"]=>
string(7) "PROJECT"
["PUBLIC"]=>
bool(false)
["PRIVAT"]=>
bool(false)
["ACCESS"]=>
int(3)
["THUMBNAIL"]=>
string(93) ""
}
[3]=>
array(9) {
["ID"]=>
string(2) "28"
["NAME"]=>
string(2) "p3"
["CREATION_DATE"]=>
string(10) "1365866780"
["CREATED_BY"]=>
string(5) "admin"
["TYPE"]=>
string(7) "PROJECT"
["PUBLIC"]=>
bool(false)
["PRIVAT"]=>
bool(false)
["ACCESS"]=>
int(3)
["THUMBNAIL"]=>
string(93) ""
}
[4]=>
array(9) {
["ID"]=>
string(2) "27"
["NAME"]=>
string(2) "p2"
["CREATION_DATE"]=>
string(10) "1365866773"
["CREATED_BY"]=>
string(5) "admin"
["TYPE"]=>
string(7) "PROJECT"
["PUBLIC"]=>
bool(false)
["PRIVAT"]=>
bool(false)
["ACCESS"]=>
int(3)
["THUMBNAIL"]=>
string(93) ""
}
[5]=>
array(9) {
["ID"]=>
string(2) "26"
["NAME"]=>
string(2) "p1"
["CREATION_DATE"]=>
string(10) "1365866767"
["CREATED_BY"]=>
string(5) "admin"
["TYPE"]=>
string(7) "PROJECT"
["PUBLIC"]=>
bool(false)
["PRIVAT"]=>
bool(false)
["ACCESS"]=>
int(3)
["THUMBNAIL"]=>
string(93) ""
}
[6]=>
array(9) {
["ID"]=>
string(1) "4"
["NAME"]=>
string(13) "Testimmortals"
["CREATION_DATE"]=>
string(10) "1362388820"
["CREATED_BY"]=>
string(5) "admin"
["TYPE"]=>
string(7) "PROJECT"
["PUBLIC"]=>
bool(false)
["PRIVAT"]=>
bool(false)
["ACCESS"]=>
int(3)
["THUMBNAIL"]=>
string(92) ""
}
}
}
那麼,由於字符串已經是錯誤的,它不是json解碼的錯誤..我認爲它甚至是api ..讓我深入這個.. – user1108319
好吧,看起來像我修復它 - > json_encode( $ array,JSON_FORCE_OBJECT)錯過了這個力量。 – user1108319
所以問題出自你的PHP文件? –