Pick values out of nested JSON with paths
REST APIs often return objects inside objects, and lists inside those. AutomatedOn uses a simple path style to reach into them. You use paths in a REST dataset's Select, Items Path, Next Value Path and Total Path, and in rule conditions.
Path examples
| Path | Returns |
|---|---|
sessionId | A top-level value. |
user.userId | A value inside a nested object. You can also write user/userId. |
user.emails[0] | The first item in a list. Counting starts at 0. |
courses[*].code | The code of every item in courses, as a list. courses[].code means the same. |
How values come out
- Names are matched exactly first, then without worrying about capitals.
- A path that doesn't exist in an item gives an empty value, not an error.
- A path to a whole object or list gives its JSON text.
- A
[*]path gives a list, written as JSON, such as["MAT2","ENG1"].
Using [*] paths in rules
A rule condition on a [*] path checks each item in the list. equal, contains, in and the comparison operators match when any item matches. not_equal, does_not_contain and not_in match when no item matches. An empty list behaves like an empty value.
Finding the right path
The field list in Select shows the paths found in a sample of up to 20 items from the first page, with lists written as [*]. If the path you need isn't there, for example because the sample didn't include it, type it in.