admin管理员组文章数量:1287555
I have a small question :
If I have a JSON array:
{
"cate_user_res_id": "4",
"from": "url",
"mimetype": "image/jpeg",
"ext": "jpg",
"res_name": ".jpg",
"user_id": "1",
"file_size": 55966,
"created": "2011-12-19 03:29:45",
"type": "i"
}
How can i get data of ["res_name"]
index?
I alert data['res_name']
it result undefined.
Thanks for any suggestion!
I have a small question :
If I have a JSON array:
{
"cate_user_res_id": "4",
"from": "url",
"mimetype": "image/jpeg",
"ext": "jpg",
"res_name": "http://watermarked.cutcaster./cutcasterglobe.jpg",
"user_id": "1",
"file_size": 55966,
"created": "2011-12-19 03:29:45",
"type": "i"
}
How can i get data of ["res_name"]
index?
I alert data['res_name']
it result undefined.
Thanks for any suggestion!
Share Improve this question edited Dec 19, 2011 at 9:37 David Z 132k29 gold badges263 silver badges284 bronze badges asked Dec 19, 2011 at 8:35 johnITBonucjohnITBonuc 1611 gold badge2 silver badges10 bronze badges3 Answers
Reset to default 4You need to parse to Javascript object first from the JSON array.
//var data = JSON.parse("<JSON string>");
var data = JSON.parse('{ "res_name" : " stackoverflow" }');
//Then you can get your value easily.
console.log(data.res_name);
console.log(data['res_name']);
Check this tutorial, would be helpful: http://geochalkboard.wordpress./2009/08/03/reading-json-data-with-dojo/
var obj = dojo.fromJson(json);
console.log(obj.res_name);
本文标签: javascriptHow can I get data from an Json array in DOJOStack Overflow
版权声明:本文标题:javascript - How can I get data from an Json array in DOJO? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741268039a2368854.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论