title: Retrieve strings from JSON array using Jackson
body: <p>I've found several answers that are close to what I'm trying to do, but not enough that I've been able to get it to work. I have a bunch of JSON that looks like this example (only actually several levels deeper and with hundreds of items at the level I want to access): <code>{"query":{"pages":{"links":[{"word":"bobsyeruncle","code":4},{"word":"easyaspie","code":3}]}}}</code>. I can't change the format; it's someone else's API. There's quite a lot of this that I don't need; in fact I only want something like an array of ["bobsyeruncle","easyaspie"]. (Or a List or whatever.)</p>
  
  <p>I experimented with a simpler version of the JSON that didn't have an array, and was able to access a single string easily using the rootNode.get("query").get("pages")... way described in <a href="https://stackoverflow.com/questions/338586/a-better-java-json-library/338608#338608">https://stackoverflow.com/questions/338586/a-better-java-json-library/338608#338608</a>. But I haven't been able to get at the array that way. Most of the answers I've found here assume that I want to create a POJO like "Links" that includes both "word" and "code," which I don't. In order to access the strings I want, is it necessary to create something like a list of "Links" that include both "word" and "code" and then ignore "code"? That doesn't seem right.</p>
  
  <p>(Also, if anyone could point me to documentation/tutorials somewhere in between the JacksonInFiveMinutes tutorial and the whole javadoc, I'm sure that would help too.)</p>
  
  <p>ETA this worked, I think!:</p>
  
  <pre><code>            String theJsonString = "{\"query\":{\"pages\":{\"links\":"
                  + "[{\"word\":\"bobsyeruncle\"},{\"word\":\"easyaspie\"}]}}}";
          ObjectMapper mapper = new ObjectMapper();
          JsonNode rootNode = mapper.readTree(theJsonString);
          JsonNode interestingObjectNode = rootNode.path("query").path("pages").path("links");
          for (int i = 0; i &lt; interestingObjectNode.size(); i ++) {
              System.out.println(interestingObjectNode.get(i).path("word").asText());
          }
  </code></pre>