SHARE
TWEET

parse.java

SpringLightking May 24th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  private static final ObjectMapper mapper = new ObjectMapper();
  2.  
  3.     public static void main(String[] args) throws Exception {
  4.  
  5.         JsonNode rootArray = mapper.readTree(new File("test.json"));
  6.         for (JsonNode root : rootArray) {
  7.             long id = root.path("id").asLong();
  8.  
  9.             System.out.println(id);
  10.             JsonNode projectNode = root.path("projects");
  11.  
  12.             if (projectNode.isArray()) {
  13.                 for (JsonNode node : projectNode) {
  14.                     String name = node.path("name").asText();
  15.  
  16.                     JsonNode issueNode = node.path("issues");
  17.  
  18.                     if (issueNode.isArray()) {
  19.                         for (JsonNode nodeIssue : issueNode) {
  20.                             String title = nodeIssue.path("title").asText();
  21.                             System.out.println(title);
  22.                         }
  23.                     }
  24.                 }
  25.             }
  26.         }
  27.  
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top