Modern JSON interface. propositions for ECMAScript 7.
- High level methods for manipulate JSON files.
- Backward compatibility with JSON Object in Node/Browser.
- Async support (callback/promise) based on ECMAScript proposal.
JSON Future is based into a set of cool libraries to handle JSON, but some of this libraries uses promises or callback style. This library adds an extra layer to call these libraries uniformly.
npm install json-future --save
const jsonFuture = require('json-future')
Don't be afraid to replace for the default JSON
object. The library is specially designed for be compatible and don't break your code:
JSON = require('json-future')
Also you can do this action using the register
helper:
require('json-future/register')
In async
methods, if you don't provide a callback for node style, then the method return a Promise
.
Creates the string
version of the input.
Creates the object
version of the input.
Returns the parsed JSON.
Stringify and write JSON to a file atomically.
Type: string
, number
Default: \t
Indentation as a string or number of spaces.
Pass in null
for no formatting.
Type: boolean
, function
Default: false
Sort the keys recursively.
Optionally pass in a compare
function.
Type: function
Passed into JSON.stringify
.
Type: number
Default 438
(0666 in octal)
Mode used when writing the file.
MIT © Kiko Beats