我正在尝试根据匹配条件使用JSON
将JSON
转换为JOLT
。
如果'type':'true',则进行处理。
JSON
输入:
{
"features": [
{
"type": "true",
"properties": {
"class_lvl": "U",
"image_url": [
"http://www.google.com/149231_294002.jpg",
"https://www.google.com/149231_294002.jpg"
],
"review_date": "2019-03-27T15:42:02.523"
}
}
]
}
我想到的JOLT
规范并未按照我想要的方式生成:
[
{
"operation": "shift",
"spec": {
"features": {
"*": {
"properties": {
//go up one level and check if type = true then copy image URL
"@(1,type)": {
"true": {
"image_url": "Parent[&3].child.grandchild"
}
}
}
}
}
}
}
]
答案 0 :(得分:0)
此规范有效:
[
{
"operation": "shift",
"spec": {
"features": {
"*": {
//"type": "Parent[#].child.grandchild.type",
"properties": {
//go up one level and check if type = true then copy image URL
"@(1,type)": {
"true": {
"@2": "Parent[#].child.grandchild"
}
}
}
}
}
}
}
]