Understand the JSONata type system
masterJSONata is a superset of JSON. Its type system includes all standard JSON data types plus functions as first-class data types. Supported types are:
stringnumberBooleannullobjectarrayfunction
repository·master·Indexed 25 days ago
https://github.com/jsonata-js/jsonataJSONata is a lightweight query and transformation language for JSON data, providing a concise syntax for navigating, filtering, and transforming complex JSON structures. It includes a comprehensive set of aggregation, array, and boolean functions, as well as operators for comparison and boolean logic. The library is available for Node.js and browser environments (version 2.2.2).
JSONata is a superset of JSON. Its type system includes all standard JSON data types plus functions as first-class data types. Supported types are:
stringnumberBooleannullobjectarrayfunctionThe and operator returns true if both operands evaluate to true. If the operands are not Boolean types, they are cast to Boolean using the rules of the $boolean function before evaluation.
library.books["Aho" in authors and price < 50].title* wildcard instead of a specific field name to select all fields within an object.To report bugs, suspected bugs, or any unexpected behavior, open a GitHub issue. For the best assistance, include a link to the JSONata exerciser containing your source data and expression. You can generate this link using the "Share" function in the top-right of the exerciser.
To request new features or improvements, please open a GitHub enhancement request issue.
You can filter selected items at any step in a location path using a predicate expression in the form [expr]. The expression expr must evaluate to a Boolean. Each item in the selection is tested against the expression: if true, the item is kept; if false, it is removed. The expression is evaluated relative to the current context item.
Phone[type='mobile']Numeric literals follow standard JSON number syntax. You can perform arithmetic operations on numbers using the following operators:
+ (addition)- (subtraction)* (multiplication)/ (division)% (remainder/modulo)Path expressions pointing to numeric values will return those values directly.
JSONata supports string literals using single (') or double (") quotes. You can nest one type of quote inside the other without escaping. To combine strings, use the concatenation operator &. This operator is unique because it will attempt to typecast its operands to strings if they are not already strings.
Key concepts:
'string' or "string".& to join strings or cast other types to strings.You can re-order values in an array using two different methods:
$sort() function: A flexible function that supports custom comparator functions.order-by operator: A convenient syntax used directly within a path expression to sort result sequences in ascending or descending order.JSONata supports regular expressions using slash delimiters: /regex/flags.
Supported flags:
i: Ignore casem: Multiline match`/regex/flags`[expr], where expr evaluates to a Boolean. The expression is evaluated relative to the current context item being tested.jsonata-es5.js or jsonata-es5.min.js files instead of the standard package.