How can I reference this array key directly in a test? sum(quantity)
Test:
console.log(responseJson.groups[0].totals)
I need to drill down 1 more into sum(quantity)
Json Response (partial)
“groups”: [
{
“by”: {},
“totals”: {
“sum(quantity)”: 411696
},
Special characters, so instead of using dot notation, you can do the following.
let groups =
[{
"by": {},
"totals": {
"sum(quantity)": 411696
},
}]
console.log(groups[0].totals["sum(quantity)"])
Groups is an array of objects, and totals is also an object. (An array is a special type of object).
1 Like