最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to access JSON Array elements returned from an AJAX response - Stack Overflow

programmeradmin3浏览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`
}]

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 the dbID 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
Add a ment  | 

1 Answer 1

Reset to default 2

Why 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?

发布评论

评论列表(0)

  1. 暂无评论