Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended JSON parser in C? [duplicate]

Tags:

json

c

parsing

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

like image 475
Marc O'Morain Avatar asked Oct 25 '11 11:10

Marc O'Morain


People also ask

Can you use JSON in C?

Parsing JSON in C using microjson Developed originally for server-browser communication, the use of JSON has since expanded into a universal data interchange format. This tutorial will provide a simple introduction to parsing JSON strings in the C programming language using the microjson library.

What is cJSON in C?

Welcome to cJSON. It's a single file of C, and a single header file. JSON is described best here: http://www.json.org/ It's like XML, but fat-free. You use it to move data around, store things, or just generally represent your program's state.

What is JSMN?

jsmn (pronounced like 'jasmine') is a minimalistic JSON parser in C. It can be easily integrated into resource-limited or embedded projects. You can find more information about JSON format at json.org. Library sources are available at https://github.com/zserge/jsmn.

What is JSON HPP?

Tagged: JSON, C++ json. hpp is a single-header C++ library for handling JSON. It provides easy, clean ways to read from and write to JSON files.


1 Answers

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.

like image 112
Basile Starynkevitch Avatar answered Sep 27 '22 20:09

Basile Starynkevitch