detect-json-style
Windows | Mac/Linux |
---|---|
Detect JSON type from a first peek chunk of a string.
It detects the following styles
- object Array top-level nested in an object like
{"rows": [{"a": 1}, ..]
- array Array of objects
[{"a": 1}...]
- multiline JSON objects after each other
{"a: 1"}{"a": 2}
(can be ndjson)
usage
var detectJSON = var json = // json -> {style: 'object', selector: 'rows.*'}
Works well together with peek-stream
and JSONStream
. The selector
attribute is compatible with the first argument of JSONStream.parse()
.
var peek = var JSONStream = var detectJSON =