Skip to content

Document.asMap function cannot handle empty array ("x":[]) #10

@tgrall

Description

@tgrall

If the JSON document contains an empty array [] the following exception is raised

`
org.ojai.exceptions.EncodingException: Unexpected event: END_ARRAY

at org.ojai.util.MapEncoder.encodeArray(MapEncoder.java:102)
at org.ojai.util.MapEncoder.encodeMap(MapEncoder.java:72)
at org.ojai.util.MapEncoder.encode(MapEncoder.java:50)

`

I do not understand why the exception is raised here:
https://github.com/ojai/ojai/blob/v1.0/core/src/main/java/org/ojai/util/MapEncoder.java#L102

Sample code to reproduce:

Document docInArr4 = Json.newDocument(); docInArr4.set("arr4string", "string") .setArray("arr4", new String[]{} ); docInArr4.asMap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions