keys
Returns a list of all keys in a JSON or ATL object.
To test if an object contains a specific key, use hasKey instead.
Parameters
OBJECT (object)
A JSON or ATL object.
Examples
Assume a "Describe a JSON Object" project with this data:
{ "finances": { "Q1": [ {"branch": "Austin", "sales": 2454994.45, "target": 2000000}, {"branch": "Boston", "sales": 3485915.31, "target": 3500000}, {"branch": "Dallas", "value": 2657920.15, "target": 2750000}, {"branch": "Denver", "sales": 2148275.64, "target": 2000000} ] } }
The "Q1" array contains four JSON objects. Zero-based indexing applies, so the objects are indexed 0-3.
ATL in Script | Result |
---|---|
| branch, sales and target |
| branch, value and target |
The function also works on ATL objects.
ATL in Script | Result |
---|---|
[[ myObject = (product = 'Ointmo', Q1sales = 21624, Q2sales = 3071) keys(myObject) ]] | product, Q1sales and Q2 sales |