Skip to content

yosuke-furukawa/node-jsonnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

jsonnet wrapper for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published