public static void main(String[] args) throws IOException {

        ObjectMapper mapper = new ObjectMapper();



            BufferedReader bufferedReader = new BufferedReader(new FileReader("D:\\Java SE\\src\\json\\jackson_tree_model\\file.json"));

            JsonNode jsonRoot = mapper.readTree(bufferedReader);

            JsonNode jsonNode = jsonRoot.path("name");

            System.out.println(jsonNode.getTextValue());

            JsonNode jsonNode1 = jsonRoot.path("age");

            System.out.println(jsonNode1.getTextValue());

            JsonNode jsonNode2 = jsonRoot.path("messages");

            Iterator<JsonNode> nodeIterator = jsonNode2.getElements();

            while (nodeIterator.hasNext()) {

                JsonNode jsonNode3 = nodeIterator.next();
                System.out.println(jsonNode3.getTextValue());

            }


        ((ObjectNode)jsonRoot).put("nickname", "new nickname");
        ((ObjectNode)jsonRoot).put("name", "updated name");
        ((ObjectNode)jsonRoot).remove("age");


        mapper.writeValue(new File("D:\\Java SE\\src\\json\\jackson_tree_model\\file.json"), jsonRoot);

    }