johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romain Manni-Bucau (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (JOHNZON-225) Json.createObjectBuilder(Map) cannot handle non-scalar types
Date Sat, 27 Jul 2019 07:59:00 GMT

     [ https://issues.apache.org/jira/browse/JOHNZON-225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Romain Manni-Bucau resolved JOHNZON-225.
----------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.1.13

Thanks [~igreene], this had been fixed on master.

> 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
>             Fix For: 1.1.13
>
>
> 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)

Mime
View raw message