admin管理员组文章数量:1328386
how to access JSON array elements for the following JSON Code? further how do i calculate the size of the returned object array?
[
{
lastInvAmt: 0
bwHrs: 0
nbwHrs: 0
unbilledAmt: 0
unbilledHrs: 0
dbID: 0`
},{
lastInvAmt: 0
bwHrs: 0
nbwHrs: 0
unbilledAmt: 0
unbilledHrs: 0
dbID: 0`
}]
how to access JSON array elements for the following JSON Code? further how do i calculate the size of the returned object array?
[
{
lastInvAmt: 0
bwHrs: 0
nbwHrs: 0
unbilledAmt: 0
unbilledHrs: 0
dbID: 0`
},{
lastInvAmt: 0
bwHrs: 0
nbwHrs: 0
unbilledAmt: 0
unbilledHrs: 0
dbID: 0`
}]
Share
Improve this question
asked Sep 23, 2010 at 14:14
BinCodeBinCode
6334 gold badges12 silver badges22 bronze badges
2
-
2
This is not a valid JSON string; in JSON, every string, whether it represents a key or a value, should be encapsulated in double quotes (
"
). Also notice the strange backticks after thedbID
values. You can test your string with jsonlint. – Marcel Korpel Commented Sep 23, 2010 at 14:36 - Thanks i will check that out.I was also thinking the same – BinCode Commented Sep 23, 2010 at 19:37
1 Answer
Reset to default 2Why can't you assign it to variable? Or I don't understand anything? :)
edited to work with json string
var ar = eval('[
{
lastInvAmt: 0
bwHrs: 0
nbwHrs: 0
unbilledAmt: 0
unbilledHrs: 0
dbID: 0
},{
lastInvAmt: 0
bwHrs: 0
nbwHrs: 0
unbilledAmt: 0
unbilledHrs: 0
dbID: 0
}]');
Why do you have single quote dbID: 0`. Is it spelling error?
本文标签: javascriptHow to access JSON Array elements returned from an AJAX responseStack Overflow
版权声明:本文标题:javascript - How to access JSON Array elements returned from an AJAX response - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742213957a2434224.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论