JSPM

  • Created
  • Published
  • Downloads 551751
  • Score
    100M100P100Q180758F
  • License MIT

JSON query and transformation language

Package Exports

  • jsonata
  • jsonata/jsonata-es5
  • jsonata/jsonata-es5.js
  • jsonata/jsonata.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jsonata) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSONata

JSON query and transformation language

Reference implementation of the JSONata query and transformation language.

Installation

  • npm install jsonata

Quick start

In Node.js:

const jsonata = require('jsonata');

const data = {
    example: [
        {value: 4},
        {value: 7},
        {value: 13}
    ]
};

(async () => {
    const expression = jsonata('$sum(example.value)');
    const result = await expression.evaluate(data);  // returns 24
})()

In a browser:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>JSONata test</title>
    <script src="https://cdn.jsdelivr.net/npm/jsonata/jsonata.min.js"></script>
    <script>
      async function greeting() {
        var json = JSON.parse(document.getElementById('json').value);
        var result = await jsonata('"Hello, " & name').evaluate(json);
        document.getElementById('greeting').innerHTML = result;
      }
    </script>
  </head>
  <body>
    <textarea id="json">{ "name": "Wilbur" }</textarea>
    <button onclick="greeting()">Click me</button>
    <p id="greeting"></p>
  </body>
</html>

More information

Contributing

See the CONTRIBUTING.md for details of how to contribute to this repo.