需要将下面的JSON转换为所需的格式,这里SpecList
是需要转换为对象列表的字符串列表。
- 输入:**
{
"Address": "ABC",
"latitude": "xy.zx",
"longitude": "xy.zm",
"name": "name",
"pincode": "123456",
"registrationId": "xxcd",
"Doctor": [
{
"Name": "ABC",
"SpecList": [
"A",
"B",
"C"
],
"practitonerId": "z",
"location": {
"lat": "ab.cd",
"lng": "ab.cd"
}
},
{
"Name": "def",
"SpecList": [
"D",
"E"
],
"practitonerId": "22",
"location": {
"lat": "ef.gh",
"lng": "ef.gh"
}
}
]
}
- 当前Jolt规范**,但未获得所需输出:
[
{
"operation": "shift",
"spec": {
"Address": "hospitalAddress",
"latitude": "hospitalLatitude",
"longitude": "hospitalLongitude",
"name": "hospitalName",
"pincode": "hospitalPincode",
"registrationId": "hospitalRegistrationId",
"Doctor": {
"*": {
"Name": "doctors[#2].doctorName",
"practitonerId": "doctors[#2].doctorPractitionerId",
"SpecList": {
"*": {
"@": "doctors[#1].doctorSpecializations.[].specializationName"
}
}
}
}
}
}
]
- 预期产出:**
{
"hospitalAddress" : "ABC",
"hospitalLatitude" : "xy.zx",
"hospitalLongitude" : "xy.zm",
"hospitalName" : "name",
"hospitalPincode" : "123456",
"hospitalRegistrationId" : "xxcd",
"doctors" : [ {
"doctorName" : "abc",
"doctorPractitionerId" : "z",
"doctorSpecializations" : [ {
"specializationName" : "A"
}, {
"specializationName" : "B"
}, {
"specializationName": "C"
} ]
}, {
"doctorName" : "def",
"doctorPractitionerId" : "22"
"doctorSpecializations" : [ {
"specializationName" : "D"
}, {
"specializationName" : "E"
} ]
}]
}
1条答案
按热度按时间cqoc49vn1#
可以使用此等级库:
正在获取
&
数组的索引:如果您想使用
#
,您可以使用以下规格:SpecList
总结如下: