Is JSON guaranteed to be ASCII? To clarify: Any "lookup table" that maps hex values to assumed character values is a portability red flag. When using them, it's polite to add comments to explicitly call out the code page dependency and argue (from a spec or RFC, say) why that assumption is okay.
http://www.ietf.org/rfc/rfc4627 specifies that the encoding must be Unicode: "JSON text SHALL be encoded in Unicode. The default encoding is UTF-8."
Show HN: Very low footprint JSON parser in portable ANSI C
41–50 of 58 posts
Re: Show HN: Very low footprint JSON parser in portable ANSI C
#42Earlier quoted context omitted.
http://www.ietf.org/rfc/rfc4627 specifies that the encoding must be Unicode: "JSON text SHALL be encoded in Unicode. The default encoding is UTF-8."
Neither the execution nor source character set (of C) is guaranteed to be ASCII though. This makes the general parsing as well as lines like "if (c >= 'A' && c <= 'F')" non-portable.
Re: Show HN: Very low footprint JSON parser in portable ANSI C
#43I like using Jansson: http://www.digip.org/jansson/
Re: Show HN: Very low footprint JSON parser in portable ANSI C
#44Re: Show HN: Very low footprint JSON parser in portable ANSI C
#45const json_char *cur_line_begin, *i; ... top->u.dbl = strtod (i, (json_char **) &i); top->u.integer = strtol (i, (json_char **) &i, 10); Ick
Re: Show HN: Very low footprint JSON parser in portable ANSI C
#46There 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?
Re: Show HN: Very low footprint JSON parser in portable ANSI C
#47Re: Show HN: Very low footprint JSON parser in portable ANSI C
#48Where are the tests?
HN may or may not work as a code review platform, but I don't think I would use myself a 3rd party software that doesn't provide tests.
Re: Show HN: Very low footprint JSON parser in portable ANSI C
#49Re: Show HN: Very low footprint JSON parser in portable ANSI C
#50This 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.