Description
A lightweight library for compressing json data, by removing redundancy of name-value objects, and store only the values in an array.
Example usage
Define a schema in array format like this:
const schema = ["field1", "field2", "field3"];
And some data:
const feed = "[\"2020-07-07T09:55:38.920Z\",\"2020-05-07T11:19:22.179Z\",22]"
A reader:
const read = buildReader(schema)
Read the data:
const output = read(feed)
The output will look like this:
{
field1: "2020-07-07T09:55:38.920Z",
field2: "2020-05-07T11:19:22.179Z",
field3: 22
}
Example of nested data
const schema = ["field1", "field2", "field3", "objects", ["ofield1","ofield2"]];
const feed = "[\"2020-07-07T09:55:38.920Z\",\"2020-05-07T11:19:22.179Z\",22,[[\"value1\",\"value2\"],[\"value3\",\"value4\"]]]"
Output:
{
field1: "2020-07-07T09:55:38.920Z",
field2: "2020-05-07T11:19:22.179Z",
field3: 22,
objects: [
{
ofield1:"value1",
ofield2:"value2",
},
{
ofield1:"value3",
ofield2:"value4",
}
]
}