3

First of all could anyone explain to me What are differences between ObjectNode and JsonNode, and where they used?

Then if I want to convert a JSON string into ObjectNode what can I do?

littleali
  • 408
  • 1
  • 6
  • 22

1 Answers1

-1

You can do:

ObjectMapper mapper = new ObjectMapper();
JsonNode actualObj = mapper.valueToTree("{\"k1\":\"v1\"}")

JsonNode it is a super class of ObjectNode.

You can find the differences in the API.

Arian Kiehr
  • 413
  • 5
  • 13
  • getJsonFactory() and createJsonParser() is deprecated. Can I do this without deprecated functions? – littleali Jul 27 '14 at 07:21
  • 6
    I found the answer, I write it in this way and then cast JsonNode to ObjectNode: `ObjectMapper mapper = new ObjectMapper(); JsonNode actualObj = mapper.readTree(jsonString);` – littleali Jul 27 '14 at 07:28