9

Possible Duplicate:
Best Way To Parse JSON in C?

I need to parse, validate and query JSON data in a C application, and I am looking for recommendations for the best C JSON library.

The data will be input as strings (char* UTF-8 data), which I first need to validate to ensure the input is valid JSON, and then I will need to perform some simple queries (iterating over the data).

I do not need to produce JSON, I only need to consume it. I also would prefer a parser that will load the whole document into memory rather than a SAX-style parser.

Can anyone recommend a good library, or does anyone have any experience or had problems with libraries?

I have seen the list of libraries in C on JSON.org - are there any good libraries missing from this list?

My requirements are for a small library with as little code / runtime size as possible, and a permissive BSD/MIT style license, since my library will be embedded in other applications.

Thanks,

Marc

Community
  • 1
  • 1
Marc O'Morain
  • 3,699
  • 5
  • 28
  • 34

2 Answers2

5

I'm recommending Jansson, which I find quite easy to use (and which loads the JSON in memory at once). However, I don't know well all the alternatives, and I don't have a working experience of all of them.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
3

I would choose json-c which is a fast and easy to use JSON parser written in C.

mloskot
  • 37,086
  • 11
  • 109
  • 136