Basic data concepts
The main feature of Tray is that it allows you to access individual data items from service A, and insert them into service B. To use these data items, you first must familiarize yourself with some key concepts regarding data.
This will enable you to understand how data is being returned to your workflows, so that you are able to access it in the way that you need.
Exactly how the data is returned (in terms of fields and volume/complexity of data) depends on the service, but the format it is returned in is in accordance with the concepts outlined below.
Introduction to JSONCopy
When you are using service connectors and triggers in Tray, they will return data in JSON format.
So what exactly is JSON?
JSON is simply a format for displaying data, using { }
,
and [ ]
to separate and group the data together.
The following is an example of some data on a certain individual, John Doe, output in JSON format
1{2"firstName": "John",3"lastName": "doe",4"age": 26,5"address": { "streetAddress": "Love Street", "city": "Nara", "postalCode": "630-0192" },6"phoneNumbers": [7{8"type": "iPhone",9"number": "0123-4567-8888"10},11{12"type": "home",13"number": "0123-4567-8910"14}15]16}
FieldsCopy
The most basic field types are string (plain text) (e.g. "firstName": "John",
) and number (e.g. "age": 26,
)
Note that a string is contained in " "
while a number is not.
Also note that sometimes a number is a string! For example, "number": "0123-4567-8888"
This will depend on how the data is stored and returned by the service you are working with.
Please see here for more information on JSON data types.
ObjectsCopy
When you see multiple fields appear within one set of { }
this is what is called an Object.
In the above example, address is an object which contains streetAddress, city and postalCode:
1"address" : { "streetAddress": "Love Street", "city": "Nara", "postalCode" : "630-0192" },
In programming and databases, objects are used to enforce a uniform structure, i.e. an 'address' object must always contain streetAddress, city and postalCode.
ArraysCopy
When you see a list of fields or objects appear within [ ]
, this is what is called an Array.
Array is just a fancy name for 'list'!
An array could be as simple as a list of names, such as:
1"cars":[ "Ford", "BMW", "Fiat" ]
Arrays of objectsCopy
In the above example you can see that John Doe has an 'array' of phoneNumbers.
Each of these phoneNumbers is an object which contains a type and a number:
1"phoneNumbers": [2{3"type" : "iPhone",4"number": "0123-4567-8888"5},6{7"type" : "home",8"number": "0123-4567-8910"9}10]
In data received from services, it is likely that the person (i.e. John Doe) will also be an object within an array of objects.
For example you could have an array of customers or an array of employees:
1{2"employees": [3{4"firstName": "John",5"lastName": "doe",6"age": 26,7"address": {8"streetAddress": "Love Street",9"city": "Nara",10"postalCode": "630-0192"11},12"phoneNumbers": [13{14"type": "iPhone",15"number": "0123-4567-8888"16},17{18"type": "home",19"number": "0123-4567-8910"20}21]22},23{24"firstName": "Roger",25"lastName": "Ramjet",26"age": 32,27"address": {28"streetAddress": "Acacia Avenue",29"city": "New York",30"postalCode": "624-1082"31},32"phoneNumbers": [33{34"type": "android",35"number": "1111-2222-3333"36},37{38"type": "home",39"number": "4444-5555-6666"40}41]42}43]44}