3 ms·
There definitely is a lack of good JSON parsers for C. We wrote our own in QEMU. The relevant code is: http://git.qemu.org/?p=qemu.git;a=blob;f=json-lexer.c;
by aliguori 15y ago
There definitely is a lack of good JSON parsers for C. We wrote our own in QEMU. The relevant code is:
http://git.qemu.org/?p=qemu.git;a=blob;f=json-lexer.c;h=3cd3285825d1f8433da982eba6059169bd6776c3;hb=HEAD http://git.qemu.org/?p=qemu.git;a=blob;f=json-lexer.c;h=3cd3...
http://git.qemu.org/?p=qemu.git;a=blob;f=json-parser.c;h=849e2156da4e7a3fad8f890370236cb6da9be716;hb=HEAD http://git.qemu.org/?p=qemu.git;a=blob;f=json-parser.c;h=849...
Among other things, this supports streaming, is fairly fast, and has gotten a fair bit of scrutiny against malicious input.
The lexer is a hand written state machine which seems like something you should never do but turned out to be pretty reasonable.
- haberman 15y agoWhat's wrong with YAJL?
- mikehuffman 15y agoNothing is wrong with yajl it is awesome! I have used the lua module for yajl for some time with no hiccups.
- lflux 15y agoNothing, YAJL got a lot of things very right. We use it in our C daemons for a bunch of things. Not having to unpack the whole JSON into memory is pretty handy.
- adobriyan 15y agocase JSON_INTEGER: obj = QOBJECT(qint_from_int(strtoll(token_get_value(token), NULL, 10))); Why is it so hard to parse integer from string correctly?