Giter Club home page Giter Club logo

jsonata's Introduction

JSONata

Build Status Coverage Status

JSON query and transformation language

##Introduction The primary purpose of this language is to extract values from JSON documents, with the additional capabilities to combine these values using a set of basic functions and operators, and also the ability to format the output into any arbitrary JSON structure.

##Install

  • npm install jsonata

##Usage In node.js (works in v0.10 and later):

var jsonata = require("jsonata");
var data = { "example": [ {"value": 4}, {"value": 7}, {"value": 13}] };
var expression = "$sum(example.value)";
var result = jsonata(expression).evaluate(data);  // returns 24

In a browser (works in latest Chrome, Firefox, Safari):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSONata test</title>
    <script src="lib/jsonata.js"></script>
</head>
<body>
<button onclick="alert(jsonata('[1..10]').evaluate())">Click me</button>
</body>
</html>

##Tutorial A tutorial on the JSONata language is available here

##Developers If you want to run the latest code from git, here's how to get started:

  1. Clone the code:

     git clone https://github.com/jsonata-js/jsonata.git
     cd jsonata
    
  2. Install the development dependencies (there are no runtime dependencies):

     npm install
    
  3. Run the tests

     npm t
    

##Errors

If an expression throws an error, e.g. syntax error or a runtime error (type error), then the object thrown has a consistent structure containing the column number of the error, the token that caused the error, and any other relevant information, including a meaningful message string.

For example:

{ "position": 16, "token": "}", "value": "]", "message": "Syntax error: expected ']' got '}' at column 16" }

##More Information Tutorial tutorial.md Function library functions.md

Contributing

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

jsonata's People

Contributors

andrew-coleman avatar knolleary avatar mattbaileyuk avatar vladbalanescu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.