[英]JSON to JSON using JOLT Transformation
I am new to JOLT and got stuck up this requirement, i saw some examples online but in my requirement i needed to add element in a new structure. 我是JOLT的新手,并满足了这一要求,我在网上看到了一些示例,但在我的要求中,我需要在新结构中添加元素。 I hope anyone will be able to understand what i am trying to say
我希望任何人都能理解我想说的
Input JSON 输入JSON
[
{
"ROWSET": {
"ROW": {
"CLTCORP": "1000", //This is CorpId
"CTLITEM": "5000", //This is CorpItemCd
"WHID": "17", //This is WarehouseId
"CTLFAC": "AAHC", //This is FacilityName
"CORP": "001" //This is CorpItem
}
}
}
]
This is expected JSON 这是预期的JSON
{
"SupplyItemData": {
"CorpId": 1000,
"CorpItemCd": 5000
"Warehouse": [{
"WarehouseId": 17,
"FacilityName": "AAHC"
}]
"CorpItem": 001
}
}
Any help or suggestion is appreciated. 任何帮助或建议,表示赞赏。
I followed few links Transform JSON-JSON JOLT but could not relate exaclty to my use case 我关注了一些链接, 将JSON-JSON JOLT转换为JSON,但无法将其与我的用例相关
You can use the shift
operator to do this. 您可以使用
shift
运算符执行此操作。 First use the *
operator to interate through the root level array. 首先使用
*
运算符插入根级别数组。 Then inside that, simply map the fields to new field names as follows. 然后在其中,只需按如下所示将字段映射到新的字段名称。
[
{
"operation": "shift",
"spec": {
"*": {
"ROWSET": {
"ROW": {
"CLTCORP": "SupplyItemData.CorpId",
"CTLITEM": "SupplyItemData.CorpItemCd",
"WHID": "SupplyItemData.Warehouse.[0].WarehouseId",
"CTLFAC": "SupplyItemData.Warehouse.[0].FacilityName",
"CORP": "SupplyItemData.CorpItem"
}
}
}
}
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.