5 #include "libjson/json.h"
8 int main(int argc, char **argv)
12 json *oils_method, *oils_param;
14 /* build the param array */
15 oils_param = json_object_new_array();
16 json_object_array_add(oils_param, json_object_new_int(1));
17 json_object_array_add(oils_param,
18 json_object_new_string("<?xml version='1.0'?><oils:root>hi</oils:root>"));
20 /* build the method and add the params */
21 oils_method = json_object_new_object();
22 json_object_object_add( oils_method, "name", json_object_new_string("add"));
23 json_object_object_add( oils_method, "params", oils_param );
25 /* print the whole method */
26 printf( "oils_method: %s\n", json_object_to_json_string( oils_method ) );
28 /* retrieve and print the params */
29 json* params = json_object_object_get(oils_method, "params" );
30 printf( "Params:\n" );
31 printf( "%d\n", json_object_get_int( json_object_array_get_idx( params, 0 )));
32 printf( "%s\n", json_object_get_string( json_object_array_get_idx( params, 1 )));