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?