我已经成功地在jolt的帮助下压平了一个son. 扁平化的SON现在应该充当输入SON 对于以下情况:
每次情况出现时
"values-*-identifier" = "colour" AND "values-*-value" = "green"
已满,则值"green"
应替换为"gre"
.
这意味着规范必须执行带有"AND"的if/else,并必须比较密钥内的索引(该索引应该具有相同的数字),以确保该值属于标识符.
输入sson:
{
"values_0_identifier": "country",
"values_0_value": "red",
"values_0_value_unit_key": "",
"values_0_language": "",
"values_1_identifier": "metal",
"values_1_value": "red",
"values_1_value_unit_key": "",
"values_1_language": "",
"values_2_identifier": "colour",
"values_2_value": "green",
"values_2_value_unit_key": "",
"values_2_language": ""
}
期望输出
{
"values_0_identifier": "country",
"values_0_value": "red",
"values_0_value_unit_key": "",
"values_0_language": "",
"values_1_identifier": "metal",
"values_1_value": "red",
"values_1_value_unit_key": "",
"values_1_language": "",
"values_2_identifier": "colour",
"values_2_value": "gre",
"values_2_value_unit_key": "",
"values_2_language": ""
}
到目前为止我try 了这个规格
[
{
"operation": "shift",
"spec": {
"values_2_value": {
"green": {
"values_2_identifier": {
"colour": {
"#gre": "value_2_identifier"
}
}
}
},
"*": "&"
}
}
]
1st issue: my if_else condition has no result. It seems, that it is swallowing the mapped value.
2nd issue: Even when this spec should work. Of course I don't want to specify the value "-2-" within the key. Here, some kind of wildcard like -- should work. Whereby -- should naturally always have the same index.
Each kind of help will be highly appreciated. Thanks in advance for any kind of hint.