Let’s bind to some REST data. We will be using this publicly available REST source which returns standard JSON data:
Note that we are no longer using Page, but now use Page and added a Cells block. This is to allow the use of the Data block.
In the Data block we list our data sources. In our example we have only one:
JSON is the data source type that we want to use. Data blocks can contain various sources just as pages can have varying control types for children.
Users is the name to assign to our data source.
In this example we use the short form and a parameter which corresponds to the .Text property. We can specify JSON as a multiline property using the full syntax, but in this case we want to use external data obtained by REST.
To do this, we use data binding and the HTTP tag. The = signifies it is databound, and the URL parameter to the HTTP data binding expression specifies where to obtain the data.
Binding to Data
In our controls properties we use data binding to display data from our JSON data source.
In this example we use full property binding. The .Text property (via parameter) is bound to the .email field of the JSON data source named Users.
The binding starts with a . (period) which is a shortcut for data. We can also use the full syntax which is identical:
Text [b:Name:] [=.Users.name]
In this example we use markdown plus data binding. This is useful to allow data binding in the middle of an expression without binding the entire property.
Data binding in markdown uses the same data binding syntax, just surround it with markdown markers [ and ].
Text [b:City:] [=.Users.address.city]
This binding is the same as the previous, but goes into a sub field in the JSON data.