JSONata 1.2 adds more power to your queries

We are proud to announce version 1.2 of the JSONata query and transformation language. JSONata is an open source, declarative language for extracting and manipulating JSON data. It includes first-class syntax for predicate-based queries, grouping, aggregation, and formatting of the result structure.

In version 1.2, we added more built-in functions together with some extra syntax to allow query results to be sorted. Also, we’ve added support for plugging in asynchronous functions, making this library a better citizen in the Node.js ecosystem.

What’s new to JSONata 1.2?

New ‘order-by’ syntax. This new syntax allows you to specify how to order the results of a query. Without this, the results of a query will be returned in document order, or the order in which they appear in the input JSON. Using this new syntax, you can order your results according to one or more sort terms. These terms can be anything from a simple property reference to a complex expression. For example, you can set a query to order by increasing price or decreasing age, or some other metric that can be extracted from the data.As an example,
Account.Order.Product^(>Price, <Quantity)
orders the products primarily by decreasing price, but for products of the same price, by increasing quantity.

New functions. We’ve added a lot of new functions to this latest release. The last release of JSONata included some nice functionality for processing string data. For this release, we added other JSON data types. This release brings us a raft of new functions for processing numbers, arrays, and objects, bringing the total number of built-in functions to 45. And, of course, you can always extend the function library yourself, either in JSONata, or using JavaScript.

Support for asynchronous functions. From the outset, JavaScript developers have always been able to extend the built-in function library with their own functions. However, it has been incumbent on the function developer to ensure their function doesn’t block — i.e., wait for something else to happen before returning control back to JSONata. This doesn’t sit well in the modern microservices world where your extension function might want to make an HTTP request to an external system. With version 1.2, you can now write extension functions that return promises, allowing the JSONata engine to yield control and then pick up processing once the external system responds with a result.