我正在尝试解析从SocialMention返回的JSON.
以下是JSON的示例:
{"title":"Social Mention","count":100,"items":[{"title":"RT @Jason_IIATMS: More Damon-isms that'll make you wanna puke: \"Let's hope the Chinese are right when they say this is the year of the tiger!\"","description":"","link":"http:\/\/twitter.com\/NYBD\/statuses\/9495530392","timestamp":1266876271,"image":null,"embed":null,"user":"NYBD","user_image":"http:\/\/a1.twimg.com\/profile_images\/60347208\/155135_logo_final_normal.jpg","user_link":"http:\/\/twitter.com\/NYBD","user_id":3265448,"source":"twitter","favicon":"http:\/\/twitter.com\/favicon.ico","type":"microblogs","domain":"twitter.com","id":"6111418866093918428"},
Run Code Online (Sandbox Code Playgroud)
我正在使用jquery的.getJson,例如:
$.getJSON("Home/GetSocialMentionData", function (data) {
$.each(data.items, function (i, item) {
alert(i);
});
});
Run Code Online (Sandbox Code Playgroud)
我显然没有做正确的事情,因为我从来没有遇到alert(i)并经常收到JavaScript错误"Microsoft JScript运行时错误:'length'为null或不是对象"
我是JSON的新手,谷歌搜索时似乎找不到任何东西.
所以我的问题是,我如何解析结果?任何有用的建议都会很棒.
从jQuery 1.4+开始,你JSON必须有效才能工作,我的意思是完全有效.您可以在此处使用JSONLint验证您的JSON .
根据您发布的内容,它无效......但似乎是一个片段,因此请输入您的完整结果,看看您是否有任何错误.
| 归档时间: |
|
| 查看次数: |
6735 次 |
| 最近记录: |