Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing JSON using C [closed]

Tags:

json

c

I'm trying to find a good way to parse JSON in C. I really don't need a huge library or anything, I would rather have something small and lightweight with a bare minimum of features, but good documentation.

Does anyone have anything they can point me to?

like image 391
dshipper Avatar asked Jul 13 '11 04:07

dshipper


People also ask

Can C parse JSON?

jsmn (pronounced like 'jasmine') is a minimalistic JSON parser in C. It can be easily integrated into the resource-limited projects or embedded systems. You can find more information about JSON format at json.org.

What is JSON object in C?

JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. Conventions used by JSON are known to programmers, which include C, C++, Java, Python, Perl, etc. JSON stands for JavaScript Object Notation. The format was specified by Douglas Crockford.

How do I read a JSON file in CPP?

Here's the code: #include <json/value. h> #include <fstream> std::ifstream people_file("people. json", std::ifstream::binary); people_file >> people; cout<<people; //This will print the entire json object. //The following lines will let you access the indexed objects.


2 Answers

Json isn't a huge language to start with, so libraries for it are likely to be small(er than Xml libraries, at least).

There are a whole ton of C libraries linked at Json.org. Maybe one of them will work well for you.

like image 160
Merlyn Morgan-Graham Avatar answered Nov 25 '22 14:11

Merlyn Morgan-Graham


cJSON has a decent API and is small (2 files, ~700 lines). Many of the other JSON parsers I looked at first were huge... I just want to parse some JSON.

Edit: We've made some improvements to cJSON over the years.

like image 21
NateS Avatar answered Nov 25 '22 15:11

NateS