jsonpath

1. java 类库

     jayway/JsonPath 

      maven 使用方法

<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
    <version>2.2.0</version>
</dependency>

  jsonpath 语法:

      

Operators

OperatorDescription
$ The root element to query. This starts all path expressions.
@ The current node being processed by a filter predicate.
* Wildcard. Available anywhere a name or numeric are required.
.. Deep scan. Available anywhere a name is required.
.<name> Dot-notated child
['<name>' (, '<name>')] Bracket-notated child or children
[<number> (, <number>)] Array index or indexes
[start:end] Array slice operator
[?(<expression>)] Filter expression. Expression must evaluate to a boolean value.

2. js 类库

      jsonpath-plus  

      npm    

      

npm install jsonpath-plus

   使用 nodeJs  broswer

   

 var JSONPath = require('jsonpath-plus');
  var result = JSONPath({json: obj, path: path});

  

<script src="lib/jsonpath.js"></script> 
  <script>
      var result = JSONPath({path: path, json: obj});
  </script> 

  

  

    

原文地址:https://www.cnblogs.com/rongfengliang/p/5938491.html