This module provides a bunch of helper functions to serialize/parse JSON data.
The core/json/stream submodule provides API to work with JSON in a stream form.
core/json/stream
import { convertIfDate } from 'core/json';import { from, pick, streamArrray } from 'core/json/stream';const parser = streamArrray(pick(from('{"data": [1, 2, 3]}'), 'data'), {reviver: convertIfDate});for await (const val of parser) { // {index: 0, value: 1} // {index: 1, value: 2} // {index: 2, value: 3} console.log(val);}
A reviver for the JSON.parse method: converts all strings that are looks like a date to Date.
JSON.parse
import { convertIfDate } from 'core/json';// trueconsole.log(JSON.parse('"2015-10-12"', convertIfDate).is(new Date(2015, 9, 12)));
Reviver for the JSON.parse method: converts all strings that are looks like a date to Date
JSON.parse('"2015-10-12"', convertIfDate) instanceof Date // true
core/json
This module provides a bunch of helper functions to serialize/parse JSON data.
Stream API
The
core/json/stream
submodule provides API to work with JSON in a stream form.Revivers
convertIfDate
A reviver for the
JSON.parse
method: converts all strings that are looks like a date to Date.