@@ -441,7 +441,11 @@ private static List<JsonObject> genImportData(List<Map<String, Object>> original
441
441
rowObject .addProperty ("double" , (Number ) row .get ("double" ));
442
442
}
443
443
rowObject .addProperty ("varchar" , row .get ("varchar" ) == null ? null : (String ) row .get ("varchar" ));
444
- rowObject .addProperty ("json" , row .get ("json" ) == null ? null : (String ) row .get ("json" ));
444
+
445
+ // Note: for JSON field, use gson.fromJson() to construct a real JsonObject
446
+ // don't use rowObject.addProperty("json", jsonContent) since the value is treated as a string, not a JsonObject
447
+ Object jsonContent = row .get ("json" );
448
+ rowObject .add ("json" , jsonContent == null ? null : GSON_INSTANCE .fromJson ((String )jsonContent , JsonElement .class ));
445
449
446
450
// vector field
447
451
rowObject .add ("float_vector" , GSON_INSTANCE .toJsonTree (row .get ("float_vector" )));
@@ -720,8 +724,8 @@ private static void comparePrint(CreateCollectionReq.CollectionSchema collection
720
724
} else if (fetchedValue instanceof Double ) {
721
725
matched = Math .abs ((Double )fetchedValue - (Double )expectedValue ) < 1e-8 ;
722
726
} else if (fetchedValue instanceof JsonElement ) {
723
- String ss = fetchedValue . toString ( );
724
- matched = ss .equals ((( String ) expectedValue ). replaceAll ( " \\ s" , "" )); // compare ignore space
727
+ JsonElement expectedJson = GSON_INSTANCE . fromJson (( String ) expectedValue , JsonElement . class );
728
+ matched = fetchedValue .equals (expectedJson );
725
729
} else if (fetchedValue instanceof ByteBuffer ) {
726
730
byte [] bb = ((ByteBuffer )fetchedValue ).array ();
727
731
matched = Arrays .equals (bb , (byte [])expectedValue );
0 commit comments