Commits

Alexander Dahl committed e516691 Draft

test a little more

Comments (0)

Files changed (1)

 #include <stdio.h>
+#include <stdbool.h>
 #include <json/json.h>
 
 int main( int argc, char **argv ) {
     char		*string = "{ \"name\" : \"joys of programming\"}";
-    json_object		*jobj = json_tokener_parse( string );
+    json_object		*jobj = json_tokener_parse( string ), *jsstr, *jsint,
+                         *jsbool, *jsarray;
     enum json_type	type = json_object_get_type( jobj );
 
-    printf( "type: %i\n", type );
+    (void) printf( "type: %i\n", type );
 
     json_object_put( jobj );
 
+    /*	second test	*/
+    jobj = json_object_new_object();
+    jsstr = json_object_new_string( "joys of irgendwas" );
+    jsint = json_object_new_int( 10 );
+    jsbool = json_object_new_boolean( true );
+    jsarray = json_object_new_array();
+
+    json_object_object_add( jobj, "site name", jsstr );
+    json_object_object_add( jobj, "isanything", jsbool );
+    json_object_object_add( jobj, "number", jsint );
+    json_object_object_add( jobj, "emptyarray", jsarray );
+
+    printf( "The json object created: %s\n",
+            json_object_to_json_string( jobj ) );
+
+    json_object_put( jobj );
+//     json_object_put( jsstr );
+//     json_object_put( jsint );
+//     json_object_put( jsbool );
+//     json_object_put( jsarray );
+
     return 0;
 }