Socket
Socket
Sign inDemoInstall

jsonata

Package Overview
Dependencies
0
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jsonata

JSON query and transformation language


Version published
Weekly downloads
407K
increased by6.62%
Maintainers
1
Install size
851 kB
Created
Weekly downloads
 

Changelog

Source

2.0.0 Major Release

Version 2.0.0 contains a breaking change to the Javascript API as a result of reimplementing the evaluator to use async functions instead of generators. This provides a performance boost. No breaking changes have been made to the JSONata language itself.

  • Faster JSONata evaluation by switching from generators to async/await (PR #583)
  • Add support for parsing binary, octal & hexadecimal numbers (PR #573)

Readme

Source

JSONata

JSON query and transformation language

NPM statistics

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.

Keywords

FAQs

Last updated on 15 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc