无法使用 jolt 解析器将一种 json 形式转换为另一种形式
unable to transform one json form to another using jolt parser
我有一个 data
如下所示:
{
"resourceType": "Immunization",
"id": "example",
"protocolApplied": [
{
"series": "2-dose",
"authority": {
"reference": "Organization/org1",
"type": "Organization",
"display": "xyz organization"
},
"targetDisease": [
{
"coding": [
{
"system": "http://snomed.info/sct",
"code": "40468003"
}
]
}
],
"doseNumberPositiveInt": 1,
"seriesDosesPositiveInt": 10
},
{
"series": "3-dose",
"targetDisease": [
{
"coding": [
{
"system": "http://snomed.info/sct",
"code": "66071002"
}
]
}
],
"doseNumberString": "one",
"seriesDosesString": "ten"
}
]
}
我需要对其进行转换以获得以下 output
:
[ {
"resourceType" : "Immunization",
"series" : "2-dose",
"reference" : "Organization/org1",
"type" : "Organization",
"display" : "xyz organization",
"targetDiseaseCodingSystem":"http://snomed.info/sct"
"targetDiseaseCode":"40468003"
"doseNumberPositiveInt" : 1,
"seriesDosesPositiveInt" : 10
}, {
"resourceType" : "Immunization",
"series" : "3-dose",
"targetDiseaseCodingSystem":"http://snomed.info/sct"
"targetDiseaseCode": "66071002"
"doseNumberString" : "one",
"seriesDosesString" : "ten"
} ]
下面是我的spec
:
[
{
"operation": "shift",
"spec": {
"protocolApplied": {
"*": {
"@(2,resourceType)": "[#2].resourceType",
"authority": {
// "reference": "reference"
"*": "[#3].&"
},
"targetDisease": {
"*": {
"coding": {
"*": {
//"*": "[#2].&"
"@(2,system)": "[#2].targetDiseaseCodingSystem"
}
}
}
},
"*": "[#2].&"
}
}
}
}
]
应用以上规格后我的输出低于:
[ {
"resourceType" : "Immunization",
"series" : "2-dose",
"reference" : "Organization/org1",
"type" : "Organization",
"display" : "xyz organization",
"doseNumberPositiveInt" : 1,
"seriesDosesPositiveInt" : 10
}, {
"resourceType" : "Immunization",
"series" : "3-dose",
"doseNumberString" : "one",
"seriesDosesString" : "ten"
} ]
其中 targetcodingsystem
和 targetdiseasecode
未填充。请帮助我。
下面的规范会有所帮助,
使用[&n]
,将值n对象移到上面。
[
{
"operation": "shift",
"spec": {
"protocolApplied": {
"*": {
"@(2,resourceType)": "[&1].resourceType",
"authority": {
"*": "[&2].&"
},
"targetDisease": {
"*": {
"coding": {
"*": {
"system": "[&5].targetDiseaseCodingSystem",
"code": "[&5].targetDiseaseCode"
}
}
}
},
"*": "[&1].&"
}
}
}
}
]
我有一个 data
如下所示:
{
"resourceType": "Immunization",
"id": "example",
"protocolApplied": [
{
"series": "2-dose",
"authority": {
"reference": "Organization/org1",
"type": "Organization",
"display": "xyz organization"
},
"targetDisease": [
{
"coding": [
{
"system": "http://snomed.info/sct",
"code": "40468003"
}
]
}
],
"doseNumberPositiveInt": 1,
"seriesDosesPositiveInt": 10
},
{
"series": "3-dose",
"targetDisease": [
{
"coding": [
{
"system": "http://snomed.info/sct",
"code": "66071002"
}
]
}
],
"doseNumberString": "one",
"seriesDosesString": "ten"
}
]
}
我需要对其进行转换以获得以下 output
:
[ {
"resourceType" : "Immunization",
"series" : "2-dose",
"reference" : "Organization/org1",
"type" : "Organization",
"display" : "xyz organization",
"targetDiseaseCodingSystem":"http://snomed.info/sct"
"targetDiseaseCode":"40468003"
"doseNumberPositiveInt" : 1,
"seriesDosesPositiveInt" : 10
}, {
"resourceType" : "Immunization",
"series" : "3-dose",
"targetDiseaseCodingSystem":"http://snomed.info/sct"
"targetDiseaseCode": "66071002"
"doseNumberString" : "one",
"seriesDosesString" : "ten"
} ]
下面是我的spec
:
[
{
"operation": "shift",
"spec": {
"protocolApplied": {
"*": {
"@(2,resourceType)": "[#2].resourceType",
"authority": {
// "reference": "reference"
"*": "[#3].&"
},
"targetDisease": {
"*": {
"coding": {
"*": {
//"*": "[#2].&"
"@(2,system)": "[#2].targetDiseaseCodingSystem"
}
}
}
},
"*": "[#2].&"
}
}
}
}
]
应用以上规格后我的输出低于:
[ {
"resourceType" : "Immunization",
"series" : "2-dose",
"reference" : "Organization/org1",
"type" : "Organization",
"display" : "xyz organization",
"doseNumberPositiveInt" : 1,
"seriesDosesPositiveInt" : 10
}, {
"resourceType" : "Immunization",
"series" : "3-dose",
"doseNumberString" : "one",
"seriesDosesString" : "ten"
} ]
其中 targetcodingsystem
和 targetdiseasecode
未填充。请帮助我。
下面的规范会有所帮助,
使用[&n]
,将值n对象移到上面。
[
{
"operation": "shift",
"spec": {
"protocolApplied": {
"*": {
"@(2,resourceType)": "[&1].resourceType",
"authority": {
"*": "[&2].&"
},
"targetDisease": {
"*": {
"coding": {
"*": {
"system": "[&5].targetDiseaseCodingSystem",
"code": "[&5].targetDiseaseCode"
}
}
}
},
"*": "[&1].&"
}
}
}
}
]