A small, flexible, and expandable JSON query language.
Documentation: https://github.com/jsonquerylang/jsonquery
name(argument1, argument2, ...)
A function is defined as a function name followed by comma separated arguments wrapped in round brackets. it is important to understand functions like filter
, sort
, and max
are executed as a method in a chain: the operation is applied to the data input, and forwarded to the next method in the chain (if any).
Examples:
sort(.address.city, "asc")
filter(.age >= 21) | sort(.age, "asc")
Documentation: Functions
Function reference:
get(prop1, prop2)
filter(condition)
sort(property, direction)
pick(property1, property2, ...)
map(query)
pipe(query1, query2, ...)
object({ prop1: query1, prop2: query2, ...)
array(query1, query2, ...)
groupBy(property)
keyBy(property)
keys()
values()
flatten()
uniq()
uniqBy(property)
limit(size)
size()
sum()
min()
max()
prod()
average()
not(value)
exists(property)
regex(text, expression, options)
round(value, digits)
abs(value)
(left operator right)
JSON Query supports all basic operators. When composing multiple operators, it is necessary to use parentheses. Operators do not have precedence since parentheses are required.
Examples:
filter(.age >= 18)
filter((.age >= 18) and (.age <= 65))
Documentation: Operators
Operator reference:
query2 | query2 | ...
A pipe is an array containing a series of queries. The queries in the pipeline are executed one by one, and the output of the first is the input for the next.
Example:
filter(.age >= 18) | sort(.name)
Documentation: Pipes
{prop1: query1, prop2: query2, ...}
An object is defined as a regular JSON object with a property name as key, and a query as value. Objects can be used to transform data or to execute multiple query pipelines in parallel.
Example:
{
names: map(.name),
numberOfNames: size()
}
Documentation: Objects
[query1, query2, ...]
An array is defined as a regular JSON array: enclosed in square brackets, with items separated by a comma.
Example:
filter(.city in ["New York", "Atlanta"])
Documentation: Arrays
.prop1.prop2
A property retrieves a property from an object. Multiple consecutive properties will retrieve a nested property.
Examples:
.age
.address.city
."first name"
Documentation: Properties