Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

When you use a Web Service interface in a Data Connector applet to retrieve or send data, the interface generally returns a response in either XML or JSON format. If the interface returns a JSON object, you must understand the basic structure of JSON and how to navigate the object to extract the specific values you require.

To navigate the elements, you must define a Locator element, using a combination of the following items:

  • Property names. Use a property name to navigate to that specific property.
  • Dots (.). Use dots to navigate to the properties of an object.
  • Brackets ([]). Use brackets with a number (n) in between to navigate to the nth+1 member of an array ([0] points to the first member).

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

Example

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

JSON
{
	"isSuccessful": true,
	"statusMessage" : "Successful retrieval",
	"data" {
		"lastUpdated": "2015-07-11 22:34:16",
		"contacts": [
			{
				"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
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.

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.

  • No labels