Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can navigate to a specific data value through multiple hierarchical levels by combining dots and square brackets in a Locator element.

Example 1

The following JSON object contains data about contacts and their news feed subscriptions:

...

LocatorData ValueExplanation
isSuccessfultrueThe value of the isSuccessful property of the root object.
data.lastUpdated

"2015-07-11 22:34:16"

The value of the lastUpdated property of the data object.
data.contacts[0].name"Joe Dow"The value of the name property of the first member of the contacts array, which is a property of the data object.
data.contacts[1].subscriptions[2]"Finance"The value of the third member of the subscriptions array, property of the second member of the contacts array, property of the data object.
data.contacts[0].age37The value of the property age of the first member of the contacts array, which is a property of the data object.
data.contacts[1].agenullThe value of a non-existing property age of the second member of the contacts array, which is a property of the data object.
data.contacts[0].subscriptions"["Science", "Engineering", "IT", "Finance"]"The value of the subscriptions property of the first member of the contacts array, property of the data object.

Example 2

The following JSON object contains just a list of contacts:

Code Block
languagejs
titleJSON
[
	{
		"name": "Joe Dow",
		"phone": "+4412341234",
		"subscriptions": ["Science", "Engineering", "IT", "Finance"],
		"age": 37			
	},
	{
		"name": "Jane Dow",
		"phone": "+4412351235",
		"subscriptions": ["Media", "Movies", "Finance", "Politics"]				
	}
]

The following Locators retrieve data from the JSON object above:

LocatorData ValueExplanation
[0].name"Joe Dow"The value of the name property of the first element in the root array.
[1].subscriptions[0]"Media"The value of the second member of the subscriptions array, property of the second member of the root array.


Info

Locators pointing to non-existing object properties or array members will retrieve null during an interaction without any indication of a failure, thus allowing any expected value to be optional.

Locators pointing to a JSON object or a JSON array rather than a simple data type value will retrieve the whole object or array and allow saving it as plain text.

...