获取jsonPath的节点名称

Extract keys from jsonPath

方法其实还是蛮简单的,就是太依赖工具了,都懒得思考最简单的方式是什么样的。当然是偶然间在报错信息中找到的思路。

  1. 先把想拿到的节点放到 hashMap 里面。
    Map<String, String> methods = JsonPath.read(file1, "$.paths");
  2. 然后直接读取 map 里的 key。
    for ( String key : methods.keySet() ) { System.out.println( key ); }

猜你喜欢

转载自www.cnblogs.com/22Kon/p/10472578.html