jstransformers / jstransformer-json

JS Transformer that minifies or beautifies JSON.
http://npmjs.com/jstransformer-json
MIT License
0 stars 0 forks source link

jstransformer-json

JSON support for JSTransformers.

Build Status Coverage Status Dependency Status NPM version

Installation

npm install jstransformer-json

API

var json = jstransformer(require('jstransformer-json'))
  , obj  = '{          "thisIsAnObject": true,\n    "that"      : [\n        "adsf","af"\n       ],\n    "este": "sí"\n}'

// when options or options.beautify is undefined, the resulting JSON is
// minified.

json.render(obj)
=> { body: '{"thisIsAnObject":true,"that":["adsf","af"],"este":"sí"}',
     dependencies: [] }

// options.beautify is the indentation used to beautify the JSON source
// (internally it is passed as the third argument to JSON.stringify()).

json.render(obj, { beautify: '    ' })
=> { body: '{\n    "thisIsAnObject": true,\n    "that": [\n        "adsf",\n        "af"\n    ],\n    "este": "sí"\n}',
     dependencies: [] }

json.render(obj, { beautify: '@@' })
=> { body: '{\n@@"thisIsAnObject": true,\n@@"that": [\n@@@@"adsf",\n@@@@"af"\n@@],\n@@"este": "sí"\n}',
     dependencies: [] }

License

MIT