postjson
v0.1.3
Published
Transforming JSON with plugins.
Downloads
7
Readme
postjson

Transforming JSON with plugins.
Install
npm i postjson --saveUsage
For more use-cases see the tests
const postjson = require('postjson')PostJSON
Initialize a PostJSON optionally with
pluginsandoptions.
Params
plugins{Array|Function}options{Object}
.use
Add a
fnas plugin.
Params
fn{Functio|Array}options{Object}returns{PostJSON}: instance for chaining
.parse
Parse a
strto abstract syntax tree (AST) and writes it to.treeproperty of thethisinstance.
Params
str{String}options{Object}returns{PostJSON}: instance for chaining
.render
Render a given
tree. Or you can just use it in combination with.parse(str)which writes thetreeto instance, then.renderwill use it. If only one argument is passed it is assumed asoptions.
Params
tree{Object}: (optional) Abstract Syntax Tree, otherwise will usethis.treeoptions{Object}returns{PostJSON}: instance for chaining
.toString
Returns stringified and already modified JSON.
Params
indent{Object}returns{String}
.process
Transforms a
valusing previously passed plugins. Think for it like.parseplus.rendercombination.
Params
val{String}options{Object}returns{PostJSON}
.walk
Temporary here, could be plugin. Part of future API sugars for working with AST.
Params
tree{Object|Array}fn{Function}returns{PostJSON}
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.
