在jsonPath我試圖過濾具有多個值的對象。一個可能的值是一個電子郵件地址。由於@被用作指向當前對象的指針,因此它失敗了。jsonPath過濾表達式與電子郵件地址
JSON字符串示例
{
"report": {
"Author": [
{
"value": "John",
"count": "58",
"fields": [
{
"key": "FileSize",
"value": "12314"
},
{
"key": "Date",
"value": "2000-01-01"
}
]
},
{
"value": "Jane",
"count": "1",
"fields": [
]
},
{
"value": "[email protected]",
"count": "58",
"fields": [
{
"key": "FileSize",
"value": "12314"
},
{
"key": "Date",
"value": "2000-01-01"
},
{
"key": "tags",
"value": "a,b,c,d"
}
]
},
{
"value": "Bill",
"count": "2",
"fields": [
{
"key": "FileSize",
"value": "14"
}
]
}
]
}
}
如果使用
$.report.Author[?(@.value==='John')]
結果是
"[{"value":"John","count":"58","fields":[{"key":"FileSize","value":"12314"},{"key":"Date","value":"2000-01-01"}]}]"
但由於電子郵件地址有一個@符號jsonPath上
返回false$.report.Author[?(@.value==='[email protected]')]
任何人都知道一種方法來逃避@符號或不同的方法來蒸發對象?