json-c / libjson Tutorial with Examples

JSON is a  data inter-exchange format. When compared to XML, it is very lightweight and more human-readable. The Data representation has some what a similar representation like C/C++ structures. It is nowadays very heavily used data format for data transfer in the web. Most languages like PHP have functions to manipulate JSON data. In case of C/C++, there are many libraries like json-c, json-glibc, jsoncpp.

  1. Introduction to JSON
  2. json-c: Installation
  3. Other libraries: json-glib: Installation
  4. Compiling a json-c program
  5. A simple and Complete Json Parser
  6. Working with json objects: Getting the type and browsing each json object
    1. json_object_get_type: Get Type of a JSON object
    2. json_object_object_foreach : Browse through every json object
    3. json_object_is_type : Check the type of a json_object
  7. Getting the value of a json object
    1. Boolean: json_object_get_boolean : Get boolean value of a json object
    2. Integers: json_object_get_int : Get integer value of a json object
    3. Strings: json_object_get_string : Get string value of a json object
  8. Creating a new json object: Integers, Booleans, Strings
    1. Json: json_object_new_object : Creating a new json object
    2. Integers: json_object_new_int: Creating an integer json object
    3. Booleans: json_object_new_boolean: Creating a boolean json object
    4. Strings: json_object_new_string: Creating a stringjson object
    5. Double(Floating Point Numbers): json_object_new_double: Creating a double json object
    6. Arrays: json_object_new_array: Creating an array json object
  9. Working with arrays
    1. Adding a json object to an array: json_object_array_add
    2. Adding a json object to an array at specified index: json_object_array_put_idx

Hope you found this tutorial useful. Please leave your valuable comments.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s