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-193) Johnzon is keeping the reference for map/values from JsonObjectBuilder.
Date Thu, 25 Oct 2018 10:42:00 GMT

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

Romain Manni-Bucau resolved JOHNZON-193.
----------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.1.11

> Johnzon is keeping the reference for map/values from JsonObjectBuilder.
> -----------------------------------------------------------------------
>
>                 Key: JOHNZON-193
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-193
>             Project: Johnzon
>          Issue Type: Bug
>            Reporter: Daniel Cunha
>            Assignee: Reinhard Sandtner
>            Priority: Major
>             Fix For: 1.1.11
>
>
> {color:#333333}If you try the follow code:{color}
>  
> {code:java}
> final JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();
> final JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder();
> IntStream.range(1, 10).forEach(numer -> {
>     jsonObjectBuilder.add("key", String.format("Key %d", numer)); 
>     jsonObjectBuilder.add("value", String.format("Value %d", numer)); 
>     jsonArrayBuilder.add(jsonObjectBuilder);
> });
> final String message = jsonArrayBuilder.build().toString();{code}
> {color:#333333}it is retuning:{color}
>  
> {code:java}
> [{"key":"Key 9","value":"Value 9"},{"key":"Key 9","value":"Value 9"},{"key":"Key 9","value":"Value
9"},{"key":"Key 9","value":"Value 9"},{"key":"Key 9","value":"Value 9"},{"key":"Key 9","value":"Value
9"},{"key":"Key 9","value":"Value 9"},{"key":"Key 9","value":"Value 9"},{"key":"Key 9","value":"Value
9"}]{code}
> {color:#333333} But we expect to see:{color}
> {code:java}
> [{"key":"Key 1","value":"Value 1"},{"key":"Key 2","value":"Value 2"},{"key":"Key 3","value":"Value
3"},{"key":"Key 4","value":"Value 4"},{"key":"Key 5","value":"Value 5"},{"key":"Key 6","value":"Value
6"},{"key":"Key 7","value":"Value 7"},{"key":"Key 8","value":"Value 8"},{"key":"Key 9","value":"Value
9"}]{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message