I have a large JSON object which is being returned from QuickBooks Online API. It is valid JSON and shows up on the console (after logging it).
Upon inspecting the console, I see the following:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
Which can be expanded to:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
0: Object
1: Object
2: Object
3: Object
4: Object
5: Object
6: Object
7: Object
8: Object
9: Object
10: Object
11: Object
12: Object
13: Object
14: Object
15: Object
16: Object
17: Object
18: Object
19: Object
20: Object
21: Object
22: Object
23: Object
24: Object
length: 25
__proto__: Array[0]
0: Object expands to:
0: Object
*_data: Object
$$hashKey: "object:82"
__proto__: Object
*_data: Object expands to:
Active: Array[1]
Balance: Array[1]
BalanceWithJobs: Array[1]
BillAddr: Array[1]
BillWithParent: Array[1]
DisplayName: Array[1]
FamilyName: Array[1]
Fax: Array[1]
FullyQualifiedName: Array[1]
GivenName: Array[1]
Id: Array[1]
Job: Array[1]
MetaData: Array[1]
Mobile: Array[1]
PreferredDeliveryMethod: Array[1]
PrimaryEmailAddr: Array[1]
PrimaryPhone: Array[1]
PrintOnCheckName: Array[1]
SalesTermRef: Array[1]
SyncToken: Array[1]
Taxable: Array[1]
I'm trying to access a property called DisplayName.
The Angular code that is being used to console.log the json data:
$http.get('/customer').success(function(customers) {
$scope.customers = customers;
console.log($scope.customers[0]["*_data"].DisplayName[0]);
});
How can this be done? Can something be typed in the console to return its value?
Update:
I can access the object using:
console.log($scope.customers[0]);
However, *_data is an object. I was thinking something like:
console.log($scope.customers[0].*_data); would work however, I receive the error:
Uncaught SyntaxError: Unexpected token *.
<thisjson>[0]["*_data"]["DisplayName"];?Uncaught SyntaxError: Unexpected token <And without the brackets,thisjsonis not defined.<thisjson>to be used literally, just as a placeholder for whatever variable you store the json in.console.log($scope.customers[0]);returns anobjectin the console. How can I access an object?console.log($scope.customers[0]["*_data"]);returns undefined.