qb-json-tok-writer
v2.1.1
Published
Quick writer for transforming tokenized JSON back into JSON/UTF-8 output (works with qb-json-tok)
Downloads
5
Maintainers
Readme
qb-json-tok-writer
Quick JSON writer for transforming tokenized output from qb-json-tok back into JSON/UTF-8 output.
Complies with the 100% test coverage and minimum dependency requirements of qb-standard .
Install
npm install qb-json-tok-writer
API 1.x -> 2.x update
qb-json-tok-writer 2.1.0 works with the updated qb-json-tok 2.1.0 output. (versioning was kept in sync for clarity).
Example
var utf8 = require( 'qb-utf8-ez' ); // for transforming to/from UTF-8
var tokenize = require( 'qb-json-tok' );
var writer = require( 'qb-json-tok-writer' );
var w = writer();
var dst = [];
var di = 0;
tokenize(
utf8.buffer( '{ "a":1, "b": [1,2,3], "c": true, "d": null }' ),
function() {
di = w.write( arguments, dst, di );
}
)
console.log( utf8.string( dst ) );
> {"a":1,"b":[1,2,3],"c":true,"d":null}