vue-cli3 引入 font-awesome的操作
阿新 • • 發佈:2020-08-11
這裡有個表格,說明JSONPath語法元素和對應XPath元素的對比。
XPath | JSONPath | Description |
/ | $ | 表示根元素 |
. | @ | 當前元素 |
/ | . or [] | 子元素 |
.. | n/a | 父元素 |
// | .. | 遞迴下降,JSONPath是從E4X借鑑的。 |
* | * | 萬用字元,表示所有的元素 |
@ | n/a | 屬性訪問字元 |
[] | [] | 子元素操作符 |
| | [,] | 連線操作符在XPath 結果合併其它結點集合。JSONP允許name或者陣列索引。 |
n/a | [start:end:step] | 陣列分割操作從ES4借鑑。 |
[] | ?() | 應用過濾表示式 |
n/a | () | 指令碼表示式,使用在指令碼引擎下面。 |
() | n/a | Xpath分組 |
- []在xpath表示式總是從前面的路徑來運算元組,索引是從1開始。
- 使用JOSNPath的[]操作符操作一個物件或者陣列,索引是從0開始。
- SONPath 例子
{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } } }
XPath | JSONPath | 結果 |
/store/book/author |
$.store.book[*].author |
書點所有書的作者 |
//author |
$..author |
所有的作者 |
/store/* |
$.store.* |
store的所有元素。所有的bookst和bicycle |
/store//price |
$.store..price |
store裡面所有東西的price |
//book[3] |
$..book[2] |
第三個書 |
//book[last()] |
$..book[(@.length-1)] |
最後一本書 |
//book[position()<3] |
$..book[0,1] $..book[:2]
|
前面的兩本書。 |
//book[isbn] |
$..book[?(@.isbn)] |
過濾出所有的包含isbn的書。 |
//book[price<10] |
$..book[?(@.price<10)] |
過濾出價格低於10的書。 |
//* |
$..* |
所有元素。 |