实在看不出我这个json数据格式有什么问题了,高手们帮帮忙吧~
{"result":200,"revision":4,"changeset":[{"sync_action":"modify","sync_type":"contact_info","detail":{"remote_contact_id":"4ecaff41af4908980b000000","share_id":null,"user_id":null,"name":"\u6d4b\u8bd5\u8054\u7cfb\u4eba","picture":"","circles":[],"share_namecard":null,"notes":"","contact_ext_info":[{"tag":"TYPE_HOME","value":"abc@sina.com","type":"email","remote_info_id":"4ecaff41-890c-491d-aed8-083c0a0a7072"},{"tag":"TYPE_HOME","value":"13854211234","type":"phone","remote_info_id":"4ecaff41-796c-4b1d-b2ed-083c0a0a7072"},{"tag":"TYPE_HOME","value":"","type":"address","remote_info_id":"4ecaff41-926c-4bcb-a320-083c0a0a7072"},{"tag":"TYPE_BIRTHDAY","value":"2011-11-16","type":"date","remote_info_id":"4ecaff41-ad60-4b50-8aaa-083c0a0a7072"},{"tag":"PROTOCOL_QQ","value":"\u5373\u65f6\u6d88\u606f","type":"im","remote_info_id":"4ecaff41-9b68-4f7c-897b-083c0a0a7072"},{"tag":"TYPE_HOME","value":"zjm.com","type":"website","remote_info_id":"4ecaff41-a464-4123-8b48-083c0a0a7072"}]}}]}
报的异常是:
org.json.
JSONException: A JSONObject text must begin with '{' at character 1 of ?{"result":200,"revision":4,"changeset":[{"sync_action":"modify","sync_type":"contact_info","detail":{"remote_contact_id":"4ecaff41af4908980b000000","share_id":null,"user_id":null,"name":"\u6d4b\u8bd5\u8054\u7cfb\u4eba","picture":"","circles":[],"share_namecard":null,"notes":"","contact_ext_info":[{"tag":"TYPE_HOME","value":"abc@sina.com","type":"email","remote_info_id":"4ecaff41-890c-491d-aed8-083c0a0a7072"},{"tag":"TYPE_HOME","value":"13854211234","type":"phone","remote_info_id":"4ecaff41-796c-4b1d-b2ed-083c0a0a7072"},{"tag":"TYPE_HOME","value":"","type":"address","remote_info_id":"4ecaff41-926c-4bcb-a320-083c0a0a7072"},{"tag":"TYPE_BIRTHDAY","value":"2011-11-16","type":"date","remote_info_id":"4ecaff41-ad60-4b50-8aaa-083c0a0a7072"},{"tag":"PROTOCOL_QQ","value":"\u5373\u65f6\u6d88\u606f","type":"im","remote_info_id":"4ecaff41-9b68-4f7c-897b-083c0a0a7072"},{"tag":"TYPE_HOME","value":"zjm.com","type":"website","remote_info_id":"4ecaff41-a464-4123-8b48-083c0a0a7072"}]}}]}
------解决方案--------------------
JSONObject需要的字符串是要以{}包括的
JSONArray则是[]包括的
------解决方案--------------------
本身没有错
------解决方案--------------------
JScript code
<h2>Test</h2>
<p>
Test: <span id="test"></span><br />
</p>
<script type="text/javascript">
var test =
{ "result":200,
"revision":4,
"changeset":[ { "sync_action":"modify",
"sync_type":"contact_info",
"detail": { "remote_contact_id":"4ecaff41af4908980b000000",
"share_id":null,
"user_id":null,
"name":"\u6d4b\u8bd5\u8054\u7cfb\u4eba",
"picture":"",
"circles":[],
"share_namecard":null,
"notes":"",
"contact_ext_info":[{ "tag":"TYPE_HOME",
"value":"abc@sina.com",
"type":"email",
"remote_info_id":"4ecaff41-890c-491d-aed8-083c0a0a7072"},
{ "tag":"TYPE_HOME",
"value":"13854211234",
"type":"phone",
"remote_info_id":"4ecaff41-796c-4b1d-b2ed-083c0a0a7072"},
{ "tag":"TYPE_HOME",
"value":"",
"type":"address",
"remote_info_id":"4ecaff41-926c-4bcb-a320-083c0a0a7072"},
{ "tag":"TYPE_BIRTHDAY",
"value":"2011-11-16",
"type":"date",
"remote_info_id":"4ecaff41-ad60-4b50-8aaa-083c0a0a7072"},
{ "tag":"PROTOCOL_QQ",
"value":"\u5373\u65f6\u6d88\u606f",
"type":"im","remote_info_id":"4ecaff41-9b68-4f7c-897b-083c0a0a7072"},
{ "tag":"TYPE_HOME",
"value":"zjm.com",
"type":"website",
"remote_info_id":"4ecaff41-a464-4123-8b48-083c0a0a7072"}
]
}
}]
}
document.getElementById("test").innerHTML=test.changeset[0].detail.contact_ext_info[1].type
</script>