0

json_object_new_int- Create a new Integer json object

Posted by Joys of Programming on in json-c

json_object_new_int is used to create a new integer json object. The syntax of the function is As you can see, it returns a pointer to the json object The following program shows the usage of the function The output of the program is something like this

Tags: , , , , ,

 
5

json_object_new_object: Creating a new Json object

Posted by Joys of Programming on in C/C++, JSON, json-c

json_object_new_object is used to create a new json object. Once you create a json object, you can add more objects to it. The syntax of the function is As you can see, it returns a pointer to the json object The following program shows the usage of the function The output of the program is [...]

Tags: , , , ,

 
0

json_object_is_type: Check the type of json object

Posted by Joys of Programming on in C/C++, JSON, json-c

json_object_is_type is used to check whether the type of the json object is same as that of the specified type. So you can easily guess that the function takes two arguments The output of the program is something like this The input to the program is

Tags: , , ,

 
3

json_object_object_get: Get a json object

Posted by Joys of Programming on in C/C++, JSON, json-c, Linux

json_object_object_get() is used to get the json object. JSON contains key:value pairs. The value can be an array, integer, boolean, double. It can also be a json object. That means to access the values within the json object, we must recursively go through json objects. The following program shows this Let’s compile the program. If [...]

Tags: , , ,

 
0

json_object_get_boolean : Get boolean value of a json object

Posted by Joys of Programming on in C/C++, JSON, json-c

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 [...]

Tags: , , , ,

 
0

json_object_object_foreach : Browse through every json object

Posted by Joys of Programming on in C/C++, JSON, json-c, Web

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 [...]

Tags: , , , ,

 
2

Compiling a json-c program in Linux

Posted by Joys of Programming on in C/C++, JSON, json-c, Web

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 [...]

Tags: , , ,

Copyright © 2009-2012 Joys of Programming All rights reserved.
Desk Mess Mirrored v1.8.1 theme from BuyNowShop.com.