In the previous chapters, we lightly introduced the idea of objects. In this chapter, we’re going to take a closer examination of what objects are and how they are used in Designer.

What are Objects?

Objects are collections of properties. A property is a key-value pair that allows you to associate a specific value with a key. For example, the following object has two properties:

{"lastName": "Russell", "firstName": "Saxifrage"}

The two keys, lastName and firstName, point to each of their respective values. In this example, “lastName” is the key for the value “Russell”, and “firstName” is the key for the value “Saxifrage”.

All values in objects are referenced by their key.

An object can contain any number of properties. Properties inside an object don’t have to have the same type as the other properties, meaning you can have an object that consists of Text, Number, True/False, and Date & Time types. You can even have an object that contains other objects.

Example:

{“lastName": "Russell", "firstName": "Saxifrage", "age": 93, "isAlive": true, "lastSeen": "2016-09-20T19:01:21.802Z"}

The above examples are written in JavaScript Object Notation (JSON).

A JSON object is always wrapped in curly braces. Properties (or key names) inside the object are enclosed in double quotes. The value associated with the key can be of any type. Properties inside an object are delimited by commas.

Using Object Functions

Inside Designer, the Object function cards can be used to interact with objects. Basic tasks, such as retrieving values or setting values on an object, can be achieved by using cards such as Get, Get Multiple, and Set.

It’s also possible to construct your own object by manually inputting value or dragging-and-dropping output fields into an Construct card.

Objects are a useful data type in that they provide an easy way to make key-value associations. Whenever you need to assign a key to a specific value, you can use an object to do so. Objects and Lists are the two data types that can encapsulate data, so it can be moved and worked with easily.

Our previous example illustrates the usefulness of objects:

{"lastName": "Russell", "firstName": "Saxifrage", "age": 93, "isAlive": true, "lastSeen": "2016-09-20T19:01:21.802Z”}

By containing all of this information in a single object, you are able to create a context. Of course, objects can be used to store information about anything you want. You create the context for the object.

The “context” of an object can also be described as its schema. A schema is a blueprint describing what will be contained within the object.

Using objects as a data structure in this way is very powerful. Many different web services leverage objects, and JSON in particular, to deliver information to other services via their API. This paradigm can be applied in many different areas.