json_object_get_string : Get string value of a json object
json_object_get_string() function is used to get the string value of a json object. The syntax It takes json_object as a parameter and returns back a string. The following program demonstrates this. the function json_parse accepts a json_object with one or more key:string pairs. Let’s compile the program. If you fail any compilation issues, refer the [...]
json_object_get_boolean : Get boolean value of a json object
json_object_get_boolean() function is used to get the boolean value of a json object. The syntax It takes json_object as a parameter and returns back an boolean. The following program demonstrates this. the function json_parse accepts a json_object with one or more key:boolean pairs. Let’s compile the program. If you fail any compilation issues, refer the [...]
json_object_get_int : Get integer value of a json object
json_object_get_int() function is used to get the integer value of a json object. The syntax It takes json_object as a parameter and returns back an integer. The following program demonstrates this. the function json_parse accepts a json_object with one or more key:integer pairs. Let’s compile the program. If you fail any compilation issues, refer the [...]
json_object_object_foreach : Browse through every json object
You can browse through every json object using the macro json_object_object_foreach The syntax where obj is the json object you want to parse, key and value correspond to key: value pairs. As mentioned before, json_object_object_foreach is a macro defined something like this So key, val are not some variables, but you can choose any random [...]
json_object_get_type: Get the type of JSON object
A json object can have any of the following types null, boolean, double, int, object, array, string, If you are working with JSON-C, you may need to know the type of every JSON object you are parsing. json_object_get_type() gives you the type of every object. The syntax of json_object_get_type() It accepts a json_object and returns [...]
Compiling a json-c program in Linux
If you have installed json-c in your machine, let’s experiment with a simple JSON program making use of JSON-C functions Let’s name the above file as json_type.c. Let’s compile it As you see, there are errors. To compile the program, we must use the “-l” option with the library name “json“. This helps in dynamic [...]
Introduction to JSON
JSON (JavaScript Object Notation) is a lightweight data-interexchange format. Prior to JSON, XML was the most commonly used data inter-exchange format. XML still has its dominance. But JSON is also gaining up because of its simplicity. JSON represents the data as string:value pairs, where the value can be string, numbers, arrays, boolean values or even [...]