jsonnet
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/jsonnet package

0.5.0-beta • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i jsonnet

Weekly Downloads

97

Version

0.5.0-beta

License

MIT

Last publish

Collaborators

  • yosuke-furukawa