1.2.1 • Published 10 years ago

cfjson v1.2.1

Weekly downloads
13
License
-
Repository
-
Last release
10 years ago

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' ] } }
1.2.1

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago