title: readValue and readTree in Jackson: when to use which?
body: <p>I'm just starting using the Jackson JSON library. Jackson is a very powerful library, but it has a terribly extensive API. A lot of things can be done in multiple ways. This makes it hard to find your way in Jackson - how to know what is the correct/best way of doing things?</p>
  
  <p>Why would I use this solution:</p>
  
  <pre><code>String json = "{\"a\":2, \"b\":\"a string\", \"c\": [6.7, 6, 5.6, 8.0]}";
  ObjectMapper mapper = new ObjectMapper();
  JsonNode node = mapper.readValue(json, JsonNode.class);
  if (node.isObject()) {
      ObjectNode obj = mapper.convertValue(node, ObjectNode.class);
      if (obj.has("a")) {
          System.out.println("a=" + obj.get("a").asDouble());
      }
  }
  </code></pre>
  
  <p>Over a solution like this:</p>
  
  <pre><code>String json = "{\"a\":2, \"b\":\"a string\", \"c\": [6.7, 6, 5.6, 8.0]}";
  ObjectMapper mapper = new ObjectMapper();
  JsonNode node = mapper.readTree(json);
  if (node.isObject()) {
      ObjectNode obj = (ObjectNode) node;
      if (obj.has("a")) {
          System.out.println("a=" + obj.get("a").asDouble());
      }
  }     
  </code></pre>
  
  <p>Or over solutions that I came across using JsonFactory and JsonParser and maybe even more options...</p>
  
  <p>It seems to mee that mapper.readValue is most generic and can be used in a lot of cases: read to JsonNode, ObjectNode, ArrayNode, PoJo, etc. So why would I want to use mapper.readTree? </p>
  
  <p>And what is the best way to convert a JsonNode to an ObjectNode? Just cast to ObjectNode? Or use something like mapper.convertValue?</p>