Skip to content

Instantly share code, notes, and snippets.

@creationix
Created December 21, 2011 15:38
Show Gist options
  • Save creationix/1506454 to your computer and use it in GitHub Desktop.
Save creationix/1506454 to your computer and use it in GitHub Desktop.
sample usage for jsonparse.
'bar'
{ foo: 'bar' }
'Hello'
'World'
[ 'Hello', 'World' ]
1
2
3
[ 1, 2, 3 ]
[ [ 'Hello', 'World' ], [ 1, 2, 3 ] ]
4
5
6
[ [ [ 'Hello', 'World' ], [ 1, 2, 3 ] ], 4, 5, 6 ]
var Parser = require('./jsonparse');
var p = new Parser();
p.onValue = onValue;
p.write('{"foo":');
p.write(' "bar');
p.write('"}');
p.write("[[[");
p.write('"Hello","World"]');
p.write(',[1,2,3],');
p.write('],4,5,6');
p.write(']');
function onValue(value) {
console.dir(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment