在 Windows 7 下针对 Android 使用 1.4.1。我有一个从 Titanium 应用程序访问的 Web 服务,该服务返回 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": "Mark@ovl.co.uk",
"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);
这将显示一个警报对话框,其中没有任何内容。Titanium HTTPClient 调用工作正常
Ti.debug(this.responseText)
没有问题。
该 JSON 也可以验证,例如在 jsonlint.com 中。