Skip to content

Collection results not supported in JAX-RS JSON responses #658

Closed
@Remigius2011

Description

@Remigius2011

When a method returns e.g. an ArrayList, the resulting JSON output is empty. This can be fixed by a small addition to JsonProvider.writeTo that looks more or less like this (I have fixed it in a subclass of JsonProvider to avoid recompiling the JAX-RS extension):

[...]
} else if (object instanceof JSONArray) {
writer.write(((JSONArray) object).toString());
// begin
} else if (object instanceof Collection) { JSONArray jsonArray = new JSONArray((Collection) object);
writer.write(jsonArray.toString());
// end
} else if (object instanceof CharSequence) {
[...]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions