JSONata

JSONata is an expression language designed to query and transform JSON data structures. The JavaScript Object Notation (JSON) is becoming the de facto standard format for exchanging data between systems over the Internet. Twitter, Facebook, and GitHub are just a few big names that provide REST APIs that exchange JSON payloads. JSON’s key strengths are its lightweight syntax and its simple data model, which have helped propel it to the dominant payload format in RESTful web services.

A lightweight data format deserves a lightweight query and transformation technology. Built on the principle that simple queries are simple to write, JSONata has a very shallow learning curve. More complex expressions build naturally on concepts already mastered, with the principle of least surprise at the forefront of the language design. With a set of fully composable operators and functions, including the ability to define new functions within expressions, it imposes no limit on the complexity of your data transformation task.

JSONata is underpinned by the semantics of the location path inspired by XPath, the ability to format the output into any JSON structure inspired by XQuery, and the functional programming model inspired by Scheme.

The semantics of the location path inspired by XPath

  • Simple and intuitive syntax for selecting values within a structure.
  • Powerful predicate mechanism for complex queries and data joins.
  • Built-in functions and operators for manipulating and aggregating data.

The ability to format the output into any JSON structure inspired by XQuery

  • Standard JSON syntax used for constructing new objects and arrays.
  • Any valid JSON data is also a valid JSONata expression.
  • Allows template style queries to be constructed.

The functional programming model inspired by Scheme.

  • Implements the ‘metacircular evaluator’ described in SICP.
  • Supports user-defined functions (closures).
  • Turing complete.

The lightweight footprint of the runtime processor enables it to run in the web browser or as a node.js module with no package dependencies.

Why should I contribute?

There are numerous JSON path syntaxes, so why another one? JSONata is much more than just a JSON navigation syntax, in the same way that the latest version of XPath is much more than just an XML navigation syntax. The language naturally extends its simple query syntax with a sophisticated functional compute engine. With JSONata, you no longer have to abandon your code to switch to another language because of a complex transformation problem.

Contributions can be made to the JSONata project in several ways, especially in the development of the built-in function library. There is also much work to be done in implementing the JSONata runtime in other language environments like C, Ruby, Python, .NET, Swift, and the like.

What technology problem will I help solve?

This is fundamentally about extracting meaningful data that is buried in potentially large JSON structures. JSONata can be applied to virtually any problem that involves querying and transforming JSON data. And knowing that no matter how complex this data extraction task is, there are constructs in the JSONata language that enable it to be expressed.

How will JSONata help my business?

Move the act of querying JSON data from the IT department and put it into the hands of the line-of-business professional. Complex queries can be written without expert knowledge of a programming language. The compact nature of these queries means that JSONata expressions can be authored as single-line properties in a web or mobile application. The lightweight, browser-friendly implementation allows a user to rapidly explore and extract information without having to install software or invoke external cloud services.

 

Developer stories

  • Andrew Coleman, IBM Cloud

    I am a senior software engineer at IBM, specializing in application integration. For the past 17 years, I’ve been a key contributor to the IBM Integration Bus product. Currently, I am focusing on the integration of cloud-based services with traditional, on-premises enterprise applications. I’ve spent many years working with XPath and XQuery, and developed the...

    Continue reading Andrew Coleman, IBM Cloud

JSONata blog posts