Jackson JSON: get node name from json-tree

前端 未结 5 881
轻奢々
轻奢々 2020-12-02 19:47

How can I receive the node names from a JSON tree using Jackson? The JSON-File looks something like this:

{  
    node         


        
5条回答
  •  醉话见心
    2020-12-02 20:34

    For Jackson 2+ (com.fasterxml.jackson), the methods are little bit different:

    Iterator> nodes = rootNode.get("foo").fields();
    
    while (nodes.hasNext()) {
      Map.Entry entry = (Map.Entry) nodes.next();
    
      logger.info("key --> " + entry.getKey() + " value-->" + entry.getValue());
    }
    

提交回复
热议问题