Loading ...
Sorry, an error occurred while loading the content.

+ANOTHER+ JSON parser (cJSON), lightweight, fun and easy!

Expand Messages
  • signalzerodb
    Hi, I m terribly sorry if this post is inappropriate; I got an invitation from Douglas, and I m hoping I m not misinterpreting his intention! For fun I
    Message 1 of 1 , Aug 26, 2009

      I'm terribly sorry if this post is inappropriate; I got an invitation from Douglas, and I'm hoping I'm not misinterpreting his intention!

      For fun I recently put together a +VERY+ lightweight JSON parser as one file of ANSI C, with no external dependencies.

      Take a look here:

      I'm certainly not going to pretend it's the most robust parser in the world (it attempts to fail gracefully, rather than inform you of validation failure), and it's not perfect either (no support for UTF-16 surrogates).

      HOWEVER, it does have some functionality and attributes which I hope you might find appealing:
      - It's dumb, easy, quick and simple.
      - It's MIT license, so you're free to do as you please with it.
      - Data structure parser uses model JSON spec 1:1.
      - Syntax is EXTREMELY lean for building and extracting JSON structures. One call per value.
      - Parser structured to make writing a SAX-style interface trivial.
      - It's one file of ANSI C, and it compiles to a few k.
      - It shares the spirit of the "fat free" idea behind JSON.
      - It has NO secondary agenda. It's a JSON library. Nothing else.

      I sent Douglas an email to the effect of: "is this worthy of addition to the json.org page?". With luck, this email can be to the effect of:

      Hello JSON community!
      Is this useful?
      Should I add/remove anything?
      Does anyone have any (tiny) code that will allow me to parse the UTF16 \u tokens with surrogates without big changes?
      Is the cJSON parser sufficiently featured to be useful?
      Should I be paying more attention to validation?
      What do you think? :D

      Many thanks in advance,

    Your message has been successfully submitted and would be delivered to recipients shortly.