Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yosuke-furukawa/node-jsonnet
jsonnet wrapper for Node.js
https://github.com/yosuke-furukawa/node-jsonnet
Last synced: 1 day ago
JSON representation
jsonnet wrapper for Node.js
- Host: GitHub
- URL: https://github.com/yosuke-furukawa/node-jsonnet
- Owner: yosuke-furukawa
- License: mit
- Created: 2014-08-25T16:35:40.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T02:57:23.000Z (about 1 year ago)
- Last Synced: 2025-01-10T07:08:04.785Z (9 days ago)
- Language: JavaScript
- Size: 927 KB
- Stars: 77
- Watchers: 8
- Forks: 14
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-github-star - node-jsonnet - furukawa | 78 | (JavaScript)
README
node-jsonnet
=====================[![Build Status](https://travis-ci.org/yosuke-furukawa/node-jsonnet.svg?branch=master)](https://travis-ci.org/yosuke-furukawa/node-jsonnet)
[jsonnet](http://google.github.io/jsonnet/doc/index.html) is a DSL for JSON. Jsonnet is created by Google.
This module is a Jsonnet wrapper for Node.js
Jsonnet demo
---------------------before:
```json
// Jsonnet Example
{
person1: {
name: "Alice",
welcome: "Hello " + self.name + "!",
},
person2: self.person1 { name: "Bob" },
}
```after:
```json
{
"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](http://google.github.io/jsonnet/doc/spec.html)
How to use
--------------------```shell
$ npm install jsonnet --save
``````javascript
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);
```