SpringLightking

parse.java

May 24th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment