Skip to content
  • There are no suggestions because the search field is empty.

Power Plus - JSONata: Data Transformation Reference

Reference for JSONata, the expression language used throughout Power Plus for querying, transforming, and templating JSON data. Covers basic navigation, filters, predicates, common built-in functions ($map, $filter, $formatNumber, $fromMillis, $millis, etc.), and the [[ ... ]] template syntax used in renderer fields.

JSONata is the expression language used throughout the Power Plus framework for data transformation, field mapping, and templating. It lets you extract, transform, and format data from your datasources without writing code.

JSONata is used in two places:

  1. Datasource queries — Transform raw API responses into a clean array of items.

  2. Renderer field expressions — Map data fields to display content using the [[ ... ]] template syntax.

The [[ ... ]] Template Syntax

In renderer fields (Content, Value, Hover Content, Link URL, etc.), you embed JSONata expressions inside double brackets:

[[object.values.name]]

The object variable refers to the current data item being rendered.

Text Content Examples

Simple field access:

[[object.name]]

Formatted number:

[[ $formatNumber(object.hs_price_eur, "#,##0.00") ]]€

Date formatting:

[[ $fromMillis(object.millis, "[D01]/[M01]/[Y0001]") ]]

Conditional content:

[[if object.discount]]<span class="badge">SALE</span>[[endif]]

Loop through arrays:

[[ for item in object.values.tags ]]
<span class="tag">[[item.name]]</span>
[[ endfor ]]

Nested property access:

[[object.values.image.url]]

Image Value Examples

[[ object.values.image.url ]]
[[ object.hs_images ? object.hs_images.$split(',')[0] : '' ]]

Link URL Examples

[[object.values.link]]
[[if object.hs_sku]]product/[[object.hs_sku]][[endif]]
[[object.absolute_url]]

Datasource Query Examples

In the JSON Datasource’s JSON Query field, you write pure JSONata (no [[ ]] brackets needed).

Extract Items from an API Response

results

Extracts the results array from { "total": 42, "results": [...] }.

Navigate Nested Structures

data.items.records

Filter Items

items[status = 'active']

Only returns items where status is “active”.

Sort Items

items^(name)

Sorts by name ascending. Use ^(>name) for descending.

Transform with $map()

Convert an array of objects into a different shape:

$map(jobs, function($v) {
$merge([$v, {
'department': $v.metadata[name.$contains('Department')].value,
'employment_type': $v.metadata[name.$contains('Employment')].value
}])
})

This takes each job object, finds metadata entries by name, and merges them as flat properties.

Reshape Parallel Arrays

Convert parallel arrays (common in weather/time-series APIs) into an array of objects:

$map($.hourly.time, function($v, $i) {
{
"id": $i,
"time": $v,
"temp": $.hourly.temperature_2m[$i],
"wind": $.hourly.windspeed_10m[$i],
"millis": $toMillis($v & ":00")
}
})

Common JSONata Functions

Function

Description

Example

$string(value)

Convert to string

$string(42)"42"

$number(value)

Convert to number

$number("42")42

$length(array)

Array/string length

$length(object.tags)

$join(array, sep)

Join array into string

$join(object.tags, ", ")

$split(str, sep)

Split string into array

object.images.$split(",")

$contains(str, sub)

Check substring

object.name.$contains("Pro")

$replace(str, old, new)

Replace text

$replace(object.slug, "-", " ")

$trim(str)

Trim whitespace

$trim(object.name)

$uppercase(str)

Uppercase

$uppercase(object.code)

$lowercase(str)

Lowercase

$lowercase(object.name)

$now()

Current ISO timestamp

$now()

$millis()

Current time in ms

$millis()

$toMillis(str)

Parse ISO to ms

$toMillis("2024-01-15T10:00:00")

$fromMillis(ms, fmt)

Format ms to date string

$fromMillis(object.date, "[D01]/[M01]/[Y0001]")

$formatNumber(n, fmt)

Format number

$formatNumber(29.9, "#,##0.00")"29.90"

$sum(array)

Sum numbers

$sum(items.price)

$average(array)

Average

$average(items.rating)

$min(array)

Minimum

$min(items.price)

$max(array)

Maximum

$max(items.price)

$count(array)

Count items

$count(items)

$sort(array, fn)

Sort with comparator

$sort(items, function($a,$b){$a.price > $b.price})

$filter(array, fn)

Filter array

$filter(items, function($v){$v.active})

$map(array, fn)

Transform each item

$map(items, function($v){$v.name})

$reduce(array, fn)

Reduce to single value

$reduce(items, function($prev,$v){$prev+$v.price}, 0)

$merge(array)

Merge objects

$merge([obj1, obj2])

$keys(object)

Get object keys

$keys(object.values)

$lookup(object, key)

Get value by key

$lookup(object, "name")

$type(value)

Get type

$type(42)"number"

Date Format Patterns

The $fromMillis() function uses XPath-style date format patterns:

Pattern

Description

Example

[Y0001]

Four-digit year

2024

[M01]

Two-digit month

03

[D01]

Two-digit day

15

[H01]

Two-digit hour (24h)

14

[m01]

Two-digit minute

30

[s01]

Two-digit second

00

[MNn]

Month name

March

[FNn]

Day of week name

Friday

Example: $fromMillis(object.date, "[D01]/[M01]/[Y0001] [H01]:[m01]")15/03/2024 14:30

Number Format Patterns

The $formatNumber() function uses these patterns:

Pattern

Description

Example

#

Optional digit

$formatNumber(42, "#")42

0

Required digit (zero-padded)

$formatNumber(5, "00")05

.

Decimal point

$formatNumber(3.1, "0.00")3.10

,

Thousands separator

$formatNumber(1234, "#,##0")1,234

Template Control Flow

Conditional (if/endif)

[[if object.discount]]
<span class="discount">-[[object.discount]]%</span>
[[endif]]

Loop (for/endfor)

[[ for tag in object.values.tags ]]
<span class="tag">[[tag.name]]</span>
[[ endfor ]]

Ternary (inline conditional)

[[ object.active ? "Active" : "Inactive" ]]

Filter Expressions

In filter value fields, you can use JSONata for dynamic values:

[[$millis()]]          → current time in milliseconds
[[$now()]] → current ISO timestamp
$cartProductIds() → custom extension: array of product IDs in the cart

Data-Schema Queries

For data-schema filters, JSONata navigates the auto-generated schema:

schema.properties[name='values'].properties[name='category'].properties[name='name'].values^(value)

This finds all unique values of values.category.name in the dataset schema, sorted alphabetically.

Learn More