Skip to content

Default Unknown type is not LinkedHashMap #423

@Kai-W

Description

@Kai-W

The documentation to Unknonw Types states that the default is LinkedHashMap. Aktually a JsonObject is returned. JsonObject used to extend LinkedHashMap in 4.19.1 but since 4.19.2 implements Map

String json = "{\"test\":{}}";
ReadOptions options = new ReadOptionsBuilder().build();
System.out.println(json);
System.out.println("getUnknownTypeClass: "+ options.getUnknownTypeClass());
Object objects = JsonIo.toObjects(json,options, Object.class);
System.out.println(objects);

Results in

{"test":{}}
getUnknownTypeClass: null
JsonObject(id:-1, type:java.util.Map, target:null, line:0, col:0, size:1)

with unknownTypeClass(LinkedHashMap.class)

{"test":{}}
getUnknownTypeClass: class java.util.LinkedHashMap
{test={}}

the same behaivor is with an unknown @type and failOnUnknownType(false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions