Files
oam/knowledge base/jsonata.md
2025-11-11 11:36:19 +01:00

1.5 KiB

JSONata

TODO

JSON query and transformation language.

  1. TL;DR
  2. Further readings
    1. Sources

TL;DR

# Concatenate strings
someAttribute & 'someSuffix'
'somePrefix' & someAttribute
'somePrefix' & someAttribute & 'someSuffix'

# Join strings
$join(['somePrefix', someAttribute, 'someSuffix'], '-')

# Filter array of objects by attribute's value
users[role = "admin"]
users[role = "admin" and name = "Alice"].name

# Filter events with timestamp value in the last week
events[$toMillis(timestamp) >= $toMillis($now()) - (60 * 60 * 7 * 24 * 1000)]

# Get a random value between 0 included and 1 excluded (0<=X<1)
$random()

# Get a random object from a list
# Lists are 0-indexed
users[$floor($random()*$count($users))]

Further readings

Sources