Skip to content

JSON.Feature.READ_JSON_ARRAYS_AS_JAVA_ARRAYS does not work #27

@gpiancastelli

Description

@gpiancastelli

The following code, called on Jackson Jr. 2.6.3

JSON.std.with(JSON.Feature.READ_JSON_ARRAYS_AS_JAVA_ARRAYS)
        .arrayOfFrom(Object.class, "[]");

crashes with the following exception

java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Object[]
    at com.fasterxml.jackson.jr.ob.impl.JSONReader.readArrayOf(JSONReader.java)
    at com.fasterxml.jackson.jr.ob.JSON.arrayOfFrom(JSON.java)

However, if I remove the feature and ask Jackson Jr. to read a list from the JSON array by using listOfFrom, everything works fine.

Since even calling arrayOfFrom without the feature does not work (which I presume is due to JSON arrays indeed being read as Java Lists... but, then, what's the purpose of the arrayOfFrom method?), how else I am supposed to make Jackson Jr. return me a Java array from a JSON array?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions