Live data from Hacker News

Show HN: Very low footprint JSON parser in portable ANSI C

github.com

51–58 of 58 posts

Re: Show HN: Very low footprint JSON parser in portable ANSI C

#51

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=3cd3... 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 someth…

What's wrong with YAJL?

Nothing, 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.

Re: Show HN: Very low footprint JSON parser in portable ANSI C

#52
post #2

Here's another minimalist alternative: https://bitbucket.org/zserge/jsmn/wiki/Home I've used it and think it's pretty neat. One of these days I'll get around to releasing the helper functions we've written to make it easier to use too.

I use it as well, and I'm very happy with it! It's been running in production for quite a while now without any hiccups.

Re: Show HN: Very low footprint JSON parser in portable ANSI C

#53
you have a function which is like 700 lines long. Without actually reading much of the source, I can tell you that you're coding style is very problematic. I'd say read a book like Practical Common Lisp or similar where general coding techniques are showcased. They apply to more than just Lisp.

Hint: A JSON parser should have functions 'parse-object'/'parse-string'/'parse-number'or something!

Re: Show HN: Very low footprint JSON parser in portable ANSI C

#54

This Show HN makes me think there needs to be a site for more formalized code reviews of open software. Ideally with some great game mechanics to make sure engagement is high and thing are getting reviewed well.

As a younger programmer with great ambitions, some sort of code review site would be awesome!

http://codereview.stackexchange.com/

Re: Show HN: Very low footprint JSON parser in portable ANSI C

#55

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=3cd3... 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 someth…

  case 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?

Re: Show HN: Very low footprint JSON parser in portable ANSI C

#56

On a related note, if you want to get something done on a sunday afternoon, writing a simple recursive descent JSON parser from scratch is both doable and fun.

This should go without saying, but never use such a thing on user-supplied data.

Re: Show HN: Very low footprint JSON parser in portable ANSI C

#57

This Show HN makes me think there needs to be a site for more formalized code reviews of open software. Ideally with some great game mechanics to make sure engagement is high and thing are getting reviewed well.

I am actually working on that as we speak. Here is my (very) alpha prototype. I plan on expanding the supported languages as I roll out each iteration.

Link: http://codetique.com

Post reply on HN