johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Cunha (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JOHNZON-193) Johnzon is keeping the reference for map/values from JsonObjectBuilder.
Date Thu, 25 Oct 2018 10:18:00 GMT
Daniel Cunha created JOHNZON-193:
------------------------------------

             Summary: 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


If you try the follow code:
{color:#cc7832}final {color}JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder(){color:#cc7832};
{color}{color:#cc7832}final {color}JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder(){color:#cc7832};
{color}IntStream.range({color:#6897bb}1{color}{color:#cc7832}, {color}{color:#6897bb}10{color}).forEach(numer
-> {
    {color:#b389c5}jsonObjectBuilder{color}.add({color:#6a8759}"key"{color}{color:#cc7832},
{color}String.format({color:#6a8759}"Key %d"{color}{color:#cc7832}, {color}numer)){color:#cc7832};
{color}    {color:#b389c5}jsonObjectBuilder{color}.add({color:#6a8759}"value"{color}{color:#cc7832},
{color}String.format({color:#6a8759}"Value %d"{color}{color:#cc7832}, {color}numer)){color:#cc7832};
{color}    {color:#b389c5}jsonArrayBuilder{color}.add({color:#b389c5}jsonObjectBuilder{color}){color:#cc7832};
{color}}){color:#cc7832};
{color}{color:#cc7832}final {color}String message = jsonArrayBuilder.build().toString(){color:#cc7832};
{color}
it is retuning:
[\{"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"}]
But we expect to see:
[\{"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"}]



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

Mime
View raw message