Using HSON
Last updated
Last updated
Currently, HSON is implemented as the preferred data-source format in Sygnal's library.
SA5 Data parses HSON blocks in your page, and loads that data into internal structures which can then be data-bound to do things like;
Populating a form options field from the CMS
Embedding data into rich text blocks in a handlebars-like templated fashion
Custom summary calculations performed by your custom code against CMS data, such as inventory counts, average product price, CMS item counts, and so on.
HSON blocks are placed in Webflow's HTML Embeds, typically inside of any Collection List or Collection Page. They describe the JSON object you want to create.
Here's a very simple example of what HSON looks like.
This would be parsed as the JavaScript object;
Typically, you would use Webflow's Field embeds to compose the SA5 Data object from Webflow's CMS Embed fields. An example might look like this;
The resulting JSON object is stored in SA5's Datastore so that you can easily access all of the data on your page, even hundreds of data items.
To provide a full bridge between Webflow's CMS Data and structured JSON objects, the SA5 Data syntax has support for typed values ( string, number, boolean ), null values, nested objects, and multiline strings.
Here's a more complex HSON example, which contains typed values, and nested objects.
This generates the following JSON object;
That resulting data can be used in , or in your custom JavaScript code.
For example if this collection contained an item with a slug of 102-hemingway
, then you could access it directly through ;
See the section for more.