Skip to content

jsonata-js/jsonata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8e4abd8 · Feb 7, 2022
Jan 14, 2018
Nov 1, 2021
Feb 7, 2022
Jan 6, 2022
Jan 13, 2021
May 29, 2018
Jun 26, 2018
Jun 26, 2017
Jun 26, 2018
Dec 17, 2018
Sep 6, 2021
Feb 7, 2022
Jan 24, 2020
Sep 27, 2016
Sep 27, 2016
Feb 7, 2022
Nov 18, 2016
Mar 1, 2017
Sep 27, 2016
Jun 3, 2021
Feb 7, 2022
Apr 22, 2020
Apr 15, 2017

Repository files navigation

JSONata

JSON query and transformation language

NPM statistics

Build Status Coverage Status

Reference implementation of the JSONata query and transformation language.

Installation

  • npm install jsonata

Quick start

In Node.js:

var jsonata = require("jsonata");

var data = {
  example: [
    {value: 4},
    {value: 7},
    {value: 13}
  ]
};
var expression = jsonata("$sum(example.value)");
var result = 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>
      function greeting() {
        var json = JSON.parse(document.getElementById('json').value);
        var result = 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.