Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonata

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonata

JSON query and transformation language

  • 1.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
492K
increased by8.91%
Maintainers
1
Weekly downloads
 
Created

What is jsonata?

jsonata is a lightweight query and transformation language for JSON data. It allows you to query, transform, and manipulate JSON data with a simple and expressive syntax.

What are jsonata's main functionalities?

Querying JSON Data

This feature allows you to query JSON data using a simple and expressive syntax. In this example, we query for a person named 'John' in the 'people' array.

const jsonata = require('jsonata');
const data = { "people": [{ "name": "John", "age": 30 }, { "name": "Jane", "age": 25 }] };
const expression = jsonata('people[name="John"]');
const result = expression.evaluate(data);
console.log(result); // Output: { "name": "John", "age": 30 }

Transforming JSON Data

This feature allows you to transform JSON data into a new structure. In this example, we transform the 'people' array to have 'fullName' and 'yearsOld' properties instead of 'name' and 'age'.

const jsonata = require('jsonata');
const data = { "people": [{ "name": "John", "age": 30 }, { "name": "Jane", "age": 25 }] };
const expression = jsonata('people.{"fullName": name, "yearsOld": age}');
const result = expression.evaluate(data);
console.log(result); // Output: [{ "fullName": "John", "yearsOld": 30 }, { "fullName": "Jane", "yearsOld": 25 }]

Aggregating JSON Data

This feature allows you to perform aggregations on JSON data. In this example, we calculate the sum of ages in the 'people' array.

const jsonata = require('jsonata');
const data = { "people": [{ "name": "John", "age": 30 }, { "name": "Jane", "age": 25 }] };
const expression = jsonata('people.age.sum()');
const result = expression.evaluate(data);
console.log(result); // Output: 55

Other packages similar to jsonata

Keywords

FAQs

Package last updated on 31 Jan 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc