]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/src/libjson/oils_method.c
6a95dc42ace9a41ed3c85a4bd45369b0871fedfb
[Evergreen.git] / OpenSRF / src / libjson / oils_method.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "json.h"
6
7
8 int main(int argc, char **argv)
9 {
10
11
12         json *oils_method, *oils_param;
13
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>"));
19
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 );
24
25         /* print the whole method */
26         printf( "oils_method: %s\n", json_object_to_json_string( oils_method ) );
27
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 )));
33
34
35         return 0;
36 }