Uploaded image for project: 'Johnzon'
  1. Johnzon
  2. JOHNZON-193

Johnzon is keeping the reference for map/values from JsonObjectBuilder.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0.1
    • 1.1.11
    • None
    • None

    Description

      If you try the follow code:

      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();

      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"}]

      Attachments

        Activity

          People

            rsandtner Reinhard Sandtner
            danielsoro Daniel Cunha
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: