【发布时间】:2018-08-25 07:18:02
【问题描述】:
我有一个 json 字符串说:
{"store" : {
"book" : [
{
"category" : "reference",
"author" : "Nigel Rees",
"title" : "Sayings of the Century",
"display-price" : 8.95
},
{
"category" : "fiction",
"author" : "Evelyn Waugh",
"title" : "Sword of Honour",
"display-price" : 12.99
},
{
"category" : "fiction",
"author" : "Herman Melville",
"title" : "Moby Dick",
"isbn" : "0-553-21311-3",
"display-price" : 8.99
},
{
"category" : "fiction",
"author" : "J. R. R. Tolkien",
"title" : "The Lord of the Rings",
"isbn" : "0-395-19395-8",
"display-price" : 22.99
}
]
}
我想根据一些条件在这个字符串中添加一个新的 json 节点
example: add $.book[0].origin = 'burma' if not present
我已经搜索了一个可以做到这一点但找不到的库。我试过JsonPath。
有没有人使用过任何可以满足这个用例的库?
【问题讨论】:
标签: java jsonpath json-path-expression jayway