Transforming JSON with plugins.
npm i postjson --save
For more use-cases see the tests
const postjson = require('postjson')
Initialize a PostJSON optionally with
plugins
andoptions
.
Params
plugins
{Array|Function}options
{Object}
Add a
fn
as plugin.
Params
fn
{Functio|Array}options
{Object}returns
{PostJSON}: instance for chaining
Parse a
str
to abstract syntax tree (AST) and writes it to.tree
property of thethis
instance.
Params
str
{String}options
{Object}returns
{PostJSON}: instance for chaining
Render a given
tree
. Or you can just use it in combination with.parse(str)
which writes thetree
to instance, then.render
will use it. If only one argument is passed it is assumed asoptions
.
Params
tree
{Object}: (optional) Abstract Syntax Tree, otherwise will usethis.tree
options
{Object}returns
{PostJSON}: instance for chaining
Returns stringified and already modified JSON.
Params
indent
{Object}returns
{String}
Transforms a
val
using previously passed plugins. Think for it like.parse
plus.render
combination.
Params
val
{String}options
{Object}returns
{PostJSON}
Temporary here, could be plugin. Part of future API sugars for working with AST.
Params
tree
{Object|Array}fn
{Function}returns
{PostJSON}
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.