我有一个 json 文档,我需要对其应用 jolt 转换,感谢任何帮助。 这是我的 json 文档。
{
"name": "Wine Seller 1",
"in_stock": "3800",
"sold": "47",
"products": [
{
"product_id":"001",
"product_name":"Wine - Maipo Valle Cabernet",
"description":"Aliquam augue q\uam, sollicitudin \nvitae, \"consectetuer\" \$100eget, rutrum at"
},
{
"product_id":"002",
"product_name":"Bacardi",
"description":"Praesent blandit \lacinia erat. \n Vestibulum \"sed\" magna"
},
.,
.'
.,
.
}
我希望输出删除所有, , , 根据描述,我想把所有的 \" 都放在那里。如下所示
{
"name": "Wine Seller 1",
"in_stock": "3800",
"sold": "47",
"products": [
{
"product_id": "001",
"product_name": "Wine - Maipo Valle Cabernet",
"description": "Aliquam augue quam, sollicitudin vitae, \"consectetuer\" $100eget, rutrum at"
},
{
"product_id": "002",
"product_name": "Bacardi",
"description": "Praesent blandit lacinia erat. Vestibulum \"sed\" magna"
},
.,
.,
.,
]
}
您可以在modify转换规范中连续使用split和join函数,假设您要在修复后基于JSON数据删除
\n
和\t
组合,例如
[
{ // split the by "description" values by \n
"operation": "modify-overwrite-beta",
"spec": {
"products": {
"*": {
"description": "=split('\n',@(1,&))"
}
}
}
},
{ // get rid of "\n"s
"operation": "modify-overwrite-beta",
"spec": {
"products": {
"*": {
"description": "=join('',@(1,&))"
}
}
}
},
{ // split the by "description" values by \t
"operation": "modify-overwrite-beta",
"spec": {
"products": {
"*": {
"description": "=split('\t',@(1,&))"
}
}
}
},
{ // get rid of "\t"s
"operation": "modify-overwrite-beta",
"spec": {
"products": {
"*": {
"description": "=join('',@(1,&))"
}
}
}
}
]