- 
                Notifications
    You must be signed in to change notification settings 
- Fork 115
Closed
Description
Serializing a nestend Java object e.g. {"outer":{"inner":"value"}} results in an wrong java object. The values of the inner Object get additonally added to the outer object.
String json = "{\"outer\":{\"inner\":\"value\"}}";
System.out.println(json);
ReadOptions options = new ReadOptionsBuilder().unknownTypeClass(LinkedHashMap.class).build();
Object objects = JsonIo.toObjects(json,options, Object.class);
System.out.println(objects);
System.out.println(JsonIo.toJson(objects, null));{"outer":{"inner":"value"}}
{inner=value, outer={inner=value}}
{"@type":"LinkedHashMap","inner":"value","outer":{"@type":"LinkedHashMap","inner":"value"}}With no unknownType set or JsonObject as unkonwn type it works as expected but interestingly the resulting toJson is different. With explicit JsonObject as unknonwType there are no @type marks.
with unknownTypeClass(JsonObject.class)
JsonObject(id:-1, type:not set, target:null, line:0, col:0, size:1)
{"outer":{"inner":"value"}}without any unknownTypeClass
JsonObject(id:-1, type:java.util.Map, target:null, line:0, col:0, size:1)
{"@type":"java.util.Map","outer":{"@type":"java.util.Map","inner":"value"}}Metadata
Metadata
Assignees
Labels
No labels