Java 无法使用jolt解析器将一个json表单转换为另一个json表单
我有一个Java 无法使用jolt解析器将一个json表单转换为另一个json表单,java,json,xml,transformation,jolt,Java,Json,Xml,Transformation,Jolt,我有一个数据如下: { "resourceType": "Immunization", "id": "example", "protocolApplied": [ { "series": "2-dose", "authority": { "reference": "Organization/org1", "type": "Organization", "display": "xyz organizatio
数据
如下:
{
"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"
}
]
}
我需要对其进行转换以获得以下输出
:
[ {
"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"
} ]
[
{
"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",
"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"
} ]
[
{
"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].&"
}
}
}
}
]
你能解释一下
“*”:“[&2]。&”
,“系统”:“[&5].targetDiseaseCodingSystem”、
和“*”:“[&1]。&”
实际上我对这方面还不熟悉,所以我想了解它是如何工作的。我设计的任何东西都是通过谷歌搜索和使用我能使用的任何东西。请帮助我理解这一点,因为我不熟悉Jolt parser的东西,并且尽力学习“system”:“[&5].targetDiseaseCodingSystem”系统中的值分配给targetDiseaseCodingSystem,在上面移动5个对象。其他人也一样。