Table of Contents
JSON Data Usage Demo
Example JSON data
<json path=person> { "firstName": "James", "lastName": "Smith", "email": "james.smith@example.com|Salesman email address", "age": 30, "motorcycles": false, "cars": [ { "name":"Ford", "url": "https://ford.com", "models": [ "Fiesta", "Focus", "Mustang" ] }, { "name":"BMW", "url": "https://bmw.com", "models": [ "320", "X3", "X5" ] }, { "name":"Fiat", "url": "https://fiat.com", "models": [ "500", "Panda" ] } ] }</json>
- element: json, path: person, inline data
Extract text
Basic extractor syntax: %$ ... %
%$person.firstName% %$person.lastName% sells cars.
James Smith sells cars.
person.middleName: **%$person.middleName%**. person.cars: **%$person.cars%**. person.cars.1.models: **%$person.cars.1.models%**.
person.middleName: (null). person.cars: (array). person.cars.1.models: 320, X3, X5.
Filter
Basic syntax: %$ ... ( ... )%
Variable will be displayed, if filter evaluates to true.
This person is older than 40: %$person.firstName(person.age>40)%. This person is younger than 40: %$person.firstName(person.age<=40)%.
This person is older than 40: . This person is younger than 40: James.
Format
Basic syntax: %$ ... # ... #%
Variable may be rendered in one of the following formats: code, header, link, email, media, rss or ejs.
%$person.cars.1.models #code#%
[ "320", "X3", "X5" ]
%$person.email #email#%
Email: Salesman email address
To use Embedded JavaScript templating first enable it in the configuration settings.
%$person.firstName #ejs?<$=d.toUpperCase()$>#%
In upper case: "James"<%=d.toUpperCase()%>
Extract list
List of all properties
Syntax: %$ ... {}%
Empty curly brackets lists all properties of the variable.
%$person{}%
firstName | James |
---|---|
lastName | Smith |
james.smith@example.com|Salesman email address | |
age | 30 |
motorcycles | ☐ |
cars | (array) |
Partial list
Syntax: %$ ... { ... }%
Curly brackets may contain pairs with header description linked to path.
%$person{"First name":firstName, "Age":age, "Main car":cars.0.name, "Not existing":middleName}%
First name | James |
---|---|
Age | 30 |
Main car | Ford |
Not existing | (null) |
Format specific member
Syntax: %$ ... { ... } # ... #%
Format must contain pairs with header description linked to format.
%$person{"First name":firstName, "Email address":email, "Main car":cars.0.name} #"Email address":email#%
First name | James |
---|---|
Email address | Salesman email address |
Main car | Ford |
Extract table
Simple table
Syntax: %$ ... []%
If variable is simple double array, it can be displayed, if square brackets are added after the variable. Table has no header. If variable is not well formed, table may show unpredictable results.
%$person.cars[]%
Ford | https://ford.com | Fiesta, Focus, Mustang |
BMW | https://bmw.com | 320, X3, X5 |
Fiat | https://fiat.com | 500, Panda |
To generate table header automatically add empty curly brackets.
%$person.cars[]{}%
name | url | models |
---|---|---|
Ford | https://ford.com | Fiesta, Focus, Mustang |
BMW | https://bmw.com | 320, X3, X5 |
Fiat | https://fiat.com | 500, Panda |
Table with specified header
Syntax: %$ ... []{ ... }%
Curly brackets contain pairs with header name and path for each column.
%$person.cars[]{"Name":name, "Model 1":models.0, "Model 2":models.1, "Model 3":models.2}%
Name | Model 1 | Model 2 | Model 3 |
---|---|---|---|
Ford | Fiesta | Focus | Mustang |
BMW | 320 | X3 | X5 |
Fiat | 500 | Panda | (null) |
Table with row filter
Syntax: %$ ... [( ... )]{ ... }%
Filter rules may be added inside brackets inside square brackets. Each row will be checked against filter.
%$person.cars[(name > b and name <= fiat)]{"Name":name, "Model 1":models.0, "Model 2":models.1, "Model 3":models.2}%
Name | Model 1 | Model 2 | Model 3 |
---|---|---|---|
BMW | 320 | X3 | X5 |
Fiat | 500 | Panda | (null) |
Table with column format
Syntax: %$ ... []{ ... } # ... #%
Format must contain pairs with header description linked to format.
%$person.cars[]{"Name":name, "Webpage":url, "Models":models, "Number of models":models} #Webpage:link, "Number of models":ejs?<$=d.length$>#%
Name | Webpage | Models | Number of models |
---|---|---|---|
Ford | https://ford.com | Fiesta, Focus, Mustang | ["Fiesta","Focus","Mustang"]<%=d.length%> |
BMW | https://bmw.com | 320, X3, X5 | ["320","X3","X5"]<%=d.length%> |
Fiat | https://fiat.com | 500, Panda | ["500","Panda"]<%=d.length%> |
Show or Hide sections
Show contents only, if it matches filter inside brackets. Syntax: %$-start ( ... )% ... %$end%
%$-start (person.cars)% ==== Section about Cars ==== This section should **be visible**. %$end%
Section about Cars
This section should be visible.
%$-start (person.motorcycles)% ==== Section about Motorcycles ==== This section should not be visible. Not even in TOC. %$end%
Show or Hide inline text
Mind extra i
in %$-start
i
( … )% … %$end%
for inline text.
He sells %$-starti (person.cars)%**Cars**%$end% %$-starti (person.cars and person.motorcycles)% and %$end% %$-starti (person.motorcycles)%**Motorcycles**%$end%.
He sells Cars .