JSONPath语法备忘单

JSONPath语法备忘单

Syntax

Depending on the client used JSONPath expressions do start with $. indicating the root element. Some clients omit the leading $..

SyntaxDescription
$.store.book[0].title
store.book[0].titleWith implicit $.
$['store']['book'][0]['title']Alternative notation similar to scripting languages

Tree Traversal

SyntaxDescription
$.parentNode.childNode.fieldXPath: /parentNode/childNode/@field (content of “field” of all "childNode"s of “parentNode”)
$..anyChildNodeXPath: //anyChildNode (all children at any depth named “anyChildNode”)
$.parentNode.*XPath: /parentNode/* (all children below)

Array Access

SyntaxDescription
$.myList[0]first element
$.myList[-1]last element
$.myList[2:3]range
$.myList[0,4,5]selection

Filtering

SyntaxDescription
$.customer[?(@.car)]Only "customer"s that have attribute “car”
$.customer[?(@.car == 'Ford Fiesta')]Only "customer"s with "Ford Fiesta"s
$.customer[?(@.age > 18)]Only adults

Complex Conditions

SyntaxDescription
$.customer[?(@.age > 18 || @.car == 'Ford Fiesta')]logical or
$.customer[?(@.age < 18 && @.hobby == 'Biking' )]logical and

Output Mapping

SyntaxDescription
$.[].{Name:name, Age:age, Hobbies:details.hobbies}Mapping fields/nested fields to new set

Credits

Original author: https://gist.github.com/mackoj/5786f8b95da0a82e8e003f444c4295bf

相关工具 (17)

chmod 命令速查表
Linux 权限变更速查表
常用正则表达式备忘单
常用正则表达式模式备忘单。
CSS选择器备忘单
CSS选择器语法备忘单。
Docker Compose 备忘单
Docker Compose 格式备忘单
Docker备忘单
Docker命令备忘单。
Docker SWARM 备忘单
Docker Swarm 模式速查表
Dockerfile 备忘单
Dockerfile 语法和构建备忘单
Git语义提交备忘单
使用语义前缀提交Git的备忘单
JQ备忘单
JQ命令备忘单
JSONPath语法备忘单
JSONPath语法备忘单
Markdown备忘单
Markdown备忘单
Nano备忘单
Nano编辑器备忘单
正则表达式备忘单
JavaScript正则表达式备忘单
Sed 备忘单
sed unix 命令速查表
XPath语法备忘单
XPath语法备忘单
ZPool 备忘单
OpenZFS/ZPool 使用命令和信息
JQ/JSONPath测试器
针对JSON内容测试jq/JSONPath表达式
留言区
昵称
邮箱
网址
0/500
0 条评论
没有评论
查看更多
Powered by Twikoo v1.6.44
Twikoo 评论管理
密码