我想转换下面的diagnoses
数组,并将除sequence
之外的所有字段移动到嵌套的coding
数组中。
JSON输入
{
"diagnoses": [
{
"version": "20230607",
"code": "A100",
"display": "Diagnosis 1",
"sequence": 1
},
{
"version": "20230607",
"code": "B100",
"display": "Diagnosis 2",
"sequence": 2
}
]
}
期望输出
{
"diagnoses": [
{
"coding": [
{
"version": "20230607",
"code": "A100",
"display": "Diagnosis 1"
}
],
"sequence": 1
},
{
"coding": [
{
"version": "20230607",
"code": "B100",
"display": "Diagnosis 2"
}
],
"sequence": 2
}
]
}
我可以按照预期转换单个diagnoses
对象,但不能正确地转置数组。下面是一个转换单个diagnoses
对象的输入和规范示例。
JSON输入(单对象)
{
"version": "20230607",
"code": "A100",
"display": "Diagnosis 1",
"sequence": 1
}
震动规格
[
{
"operation": "shift",
"spec": {
"sequence": "&",
"*": "coding[0].&"
}
}
]
1条答案
按热度按时间qxgroojn1#
忽略你有两种不同类型的输入,编写自己的Jolt规范。因为你有数组输入在
sequence
键中,否则你有它们在根对象中。