0
在Windows 7使用1.4.1針對Android的我有一個Web服務是由鈦的應用程序訪問,服務返回JSON這樣的:爲什麼Appcelerator Titanium Mobile不會解析這個JSON?
{
"VFPData": {
"rows": [
{
"address1": "Orion House",
"address2": "Orion Way",
"address3": "Kettering",
"address4": "Northants",
"comp_name": "Orion Vehicles Leasing",
"contid": 1,
"email": "",
"email2": "",
"fax": "",
"firstname": "David John",
"lastname": "Sear",
"mobile": "",
"phone1": "",
"phone2": "",
"postcode": "NN15 6PE"
},
{
"address1": "Unit 20 Acton Business Park",
"address2": "Acton Lane",
"address3": "London",
"address4": "",
"comp_name": "Orion Vehicles Limited",
"contid": 2,
"email": "[email protected]",
"email2": "",
"fax": "",
"firstname": "Mark",
"lastname": "Johnson",
"mobile": "0888 566 67879",
"phone1": "0208 209 1359",
"phone2": "",
"postcode": "NW10 7NH"
}
]
}
}
但是沒有EVAL或JSON.parse的組合將返回有效的結果 - 例如:
var contacts = JSON.parse(this.responseText);
alert(contacts.length);
這將顯示一個沒有任何內容的警報對話框。鈦HTTPClient呼叫工作正常,因爲我可以
Ti.debug(this.responseText)
沒有問題。
JSON驗證OK,例如,在jsonlint.com。