Creating a json object using jackson

前端 未结 4 1992
孤城傲影
孤城傲影 2020-12-05 13:26

How can I create a json array like the example below using jackson.

I tried using ObjectMapper, but this does not seem correct.

      try (Director         


        
4条回答
  •  感动是毒
    2020-12-05 13:38

    initializing JSON object as singleton instance, and building it:

    ObjectNode node = JsonNodeFactory.instance.objectNode(); // initializing
    node.put("x", x); // building
    

    PS: to println use node.toString().

提交回复
热议问题