cfjson
v1.2.1
Published
compact and flat JSON
Downloads
3
Readme
compact and flat JSON
install:
npm install cfjson
usage:
packing
var cfjson = require('cfjson');
var p = cfjson.pack ({
foo: 1,
'bar': 2,
tar: [3,4],
om: {
o: ['m'],
m: {a:1}
}
});
the value of the p will be:
{ '670491991': 2,
'1591485485': 'm',
'2253003985': 1,
'2414502773': 1,
'2851480594': 4,
'3474143747': 3 }
unpacking
for getting value from packed object, you need schema of original object:
values in schema object doesen't matter
cfjson.unpack ({foo:null, 'om.o[0]':1}, p);
cfjson.unpack ({foo:null, om:{'o[0]':1}, p};
cfjson.unpack ({foo:null, om:{o:[0]}}, p);
the result of any line of this code are equal and will be:
{ foo: 1, om: { o: [ 'm' ] } }