8000 Document.asMap function cannot handle empty array ("x":[]) · Issue #10 · ojai/ojai · GitHub
[go: up one dir, main page]

Skip to content

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

Open

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();

Activity

  1. added a commit that references this issue on Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0