jsonnet wrapper for Node.js
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib init Aug 26, 2014
test Fix timeout Aug 26, 2014
.gitignore init Aug 26, 2014
.travis.yml
LICENSE.md Update LICENSE.md Aug 26, 2014
README.md Update README.md Aug 26, 2014
index.js init Aug 26, 2014
package.json

README.md

node-jsonnet

Build Status

jsonnet is a DSL for JSON. Jsonnet is created by Google.

This module is a Jsonnet wrapper for Node.js

Jsonnet demo

before:

// Jsonnet Example
{
    person1: {
        name: "Alice",
        welcome: "Hello " + self.name + "!",
    },
    person2: self.person1 { name: "Bob" },
}

after:

{
   "person1": {
      "name": "Alice",
      "welcome": "Hello Alice!"
   },
   "person2": {
      "name": "Bob",
      "welcome": "Hello Bob!"
   }
}

If you would like to know more Jsonnet syntax, read here.

http://google.github.io/jsonnet/doc/spec.html

How to use

$ npm install jsonnet --save
var Jsonnet = require('jsonnet');
// instance jsonnet
var jsonnet = new Jsonnet();
var fs = require('fs');

var code = fs.readFileSync("./menu.jsonnet");

// eval jsonnet to javascript object
var result = jsonnet.eval(code);

console.log(result);