1 #include "config.h" 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <string.h> 5 6 #include "json_object.h" 7 #include "json_object_iterator.h" 8 #include "json_tokener.h" 9 10 int main(int atgc, char **argv) 11 { 12 const char *input = "{\n\ 13 \"string_of_digits\": \"123\",\n\ 14 \"regular_number\": 222,\n\ 15 \"decimal_number\": 99.55,\n\ 16 \"boolean_true\": true,\n\ 17 \"boolean_false\": false,\n\ 18 \"big_number\": 2147483649,\n\ 19 \"a_null\": null,\n\ 20 }"; 21 22 struct json_object *new_obj; 23 struct json_object_iterator it; 24 struct json_object_iterator itEnd; 25 26 it = json_object_iter_init_default(); 27 new_obj = json_tokener_parse(input); 28 it = json_object_iter_begin(new_obj); 29 itEnd = json_object_iter_end(new_obj); 30 31 while (!json_object_iter_equal(&it, &itEnd)) 32 { 33 printf("%s\n", json_object_iter_peek_name(&it)); 34 printf("%s\n", json_object_to_json_string(json_object_iter_peek_value(&it))); 35 json_object_iter_next(&it); 36 } 37 38 json_object_put(new_obj); 39 40 return 0; 41 } 42
This page was automatically generated by LXR 0.3.1. • OpenWrt