2022.1

Table Of Contents
JSON snippets
JSON snippets are snippets that contain JSON data instead of text. Just like other types of
snippets, JSON snippets are stored in the Snippets folder on the Resources pane, but their
file name ends in .json.
This topic contains information that only applies to JSON snippets. If you want to know how to
add an existing (remote) snippet to the resources, or how to create an empty JSON snippet,
please see "Snippets" on page775.
Tip
It is possible to open and edit any external JSON file in the Designer: select File > Open,
select All files (*.*) as the file type and then select an HTML or JSON file.
Using a JSON snippet
Unlike HTML snippets, JSON Snippets cannot be inserted into the content directly, but they can
be accessed via a script using the loadjson() function.
To load a JSON snippet in script, use: loadjson(‘snippets/nameofthesnippet.json’).
For example:
var json_data = loadjson("snippets/snippet.json");
results.html(json_data.field1);
See also: "Writing your own scripts" on page918 and "loadjson()" on page1361.
For an example in which JSON snippets are being used to localize a template, see this how-to:
Localizing templates using json.
Handlebars templates
In OL Connect, Handlebars templates are a special kind of snippets. Just like other types of
snippets (see "Snippets" on page775), Handlebars templates are stored in the Snippets folder
on the Resources pane, but their file name ends in .hbs.
Page 781