lib/json: also check for null in Sequence
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 27 May 2013 18:16:15 +0000 (14:16 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 27 May 2013 18:16:15 +0000 (14:16 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/json/json_reader.nit
tests/sav/test_json.res

index 075d221..23611eb 100644 (file)
@@ -81,13 +81,16 @@ redef extern JsonObject
                Array dest;
                int i;
                int len;
+               enum json_type type;
 
                jlist = json_object_get_array( recv );
                len = json_object_array_length( recv );
                dest = new_Array();
                for ( i = 0; i < len; i ++ ) {
                        jobj = json_object_array_get_idx( recv, i );
-                       obj = JsonObject_json_cross( jobj, json_object_get_type( jobj ) );
+                       if ( jobj == NULL ) type = json_type_null;
+                       else type = json_object_get_type( jobj );
+                       obj = JsonObject_json_cross( jobj, type );
                        Array_push( dest, nullable_Jsonable_as_nullable_Object( obj ) );
                }
 
index 0a1cb80..8daa466 100644 (file)
@@ -1,5 +1,5 @@
 ../lib/json/json_reader.nit: In function 'JsonObject_json_to_string___impl':
-../lib/json/json_reader.nit:101:11: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
+../lib/json/json_reader.nit:104:11: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
 ../lib/json/json_writer.nit: In function 'Map_native_to_json___impl':
 ../lib/json/json_writer.nit:38:23: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
 ../lib/json/json_writer.nit:40:23: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]