Skip to content

aa6/nodejs_json_array_writable_stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodejs_json_array_writable_stream

Packing objects into JSON array.

var json_array_writable_stream = require("json-array-writable-stream")
var stream = json_array_writable_stream()
stream.write(1)
stream.write("string")
stream.write(null)
stream.write({a:"Aa"})
stream.write(void(0)) // Will ignore undefined by default
stream.end()
stream.pipe(process.stdout) // [1,"string",null,{"a":"Aa"}]

Available options:

var stream = json_array_writable_stream(
{
    spaces: 0,
    opening: "[",
    closing: "]",
    replacer: function(key, val) { return (key == "key1") ? "Replacement value." : val },
    separator: ",\n",
    replace_undefined_by: null // In case you want these keys to show up in your JSON.
})

About

Packing objects into JSON array.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published