[ https://issues.apache.org/jira/browse/JOHNZON-225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Romain Manni-Bucau reassigned JOHNZON-225: ------------------------------------------ Assignee: Romain Manni-Bucau > Json.createObjectBuilder(Map) cannot handle non-scalar types > ------------------------------------------------------------ > > Key: JOHNZON-225 > URL: https://issues.apache.org/jira/browse/JOHNZON-225 > Project: Johnzon > Issue Type: Bug > Affects Versions: 1.1.12 > Reporter: Ivan Greene > Assignee: Romain Manni-Bucau > Priority: Major > > Json.createObjectBuilder(Map<String, Object>) throws JsonException when > passed a Map who's values are non-scalar types (JsonValue subclasses such as > JsonArray/JsonObject are permitted, however). > An example: > {code:java} > @Test > public void shouldBuildJsonObjectFromMap() { > Map<String, Object> map = new HashMap<>(); > map.put("foo", "bar"); > map.put("baz", new HashMap<>()); > map.put("quux", new ArrayList<>()); > JsonObject build = Json.createObjectBuilder(map).build(); > assertThat(build.getJsonObject("baz")).isNotNull(); > } > {code} > This results in the exception "javax.json.JsonException: Illegal JSON type! > name=quux type=class java.util.ArrayList" > This is not a problem in Yasson. The spec mentions that > IllegalArgumentException should be thrown if a value from the map cannot be > converted to the corresponding JsonValue, but in this case Maps or Lists > should be converted to JsonObject or JsonArray -- This message was sent by Atlassian JIRA (v7.6.14#76016)