Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 1015 Bytes

README.md

File metadata and controls

61 lines (46 loc) · 1015 Bytes

node-jsonnet

Changes from original repository

  • Updated Jsonnet Library (Build date: 2019-03-15)
  • Updated dependencies
  • Moved all dependencies to devDependencies where they belong

Jsonnet example

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!"
   }
}

Usage

$ npm install @rbicker/jsonnet --save
const Jsonnet = require('@rbicker/jsonnet');
const fs = require('fs');

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

const jsonnet = new Jsonnet();
// eval jsonnet to json
const result = jsonnet.eval(code);

console.log(result);