Jolt 转换嵌套 Json 到扁平 Json
Jolt Transformation Nested Json to Flat Json
我和这个很亲近。但是,恐怕输出并不是我想要的。有人可以帮我更正我的 Jolt Spec 以获得我正在寻找的确切转换吗?我真的为此绞尽脑汁,非常感谢最后一点帮助。
所以目前我看起来像这样:
{
"Hdr": {
"DataSupplier": "BANK19000001",
"FeedType": "Reuse",
"SchemaVersion": "05.00",
"SeqNo": "1",
"DateProduced": "2019-09-30T11:44:12Z",
"RecordCount": 1
},
"Data": [
{
"IM_SubmitterID": "BANK19000001",
"IM_ParticipantID": "BANK19000001",
"IM_AsOfDateTime": "2019-09-30T11:44:12Z",
"IM_RepCpCodeType": "LEI",
"CP_RepCp": "549300LW9VUUMJV5HC31",
"CO_ActionType": "Normal",
"CP_EntResponsibleForRep": "549300LW9VUUMJV5HC31",
"LN_EventDate": "2019-09-30",
"Clltrl": [
{
"CO_TypeOfCollComponent": "SECU",
"CO_IdOfASecUsedAsColl": "FR0000131104",
"RU_ValueOfReusedColl": "1000000",
"RU_EstimatedReuseOfColl": "500000",
"RU_ReusedCollCcy": "EUR"
},
{
"CO_TypeOfCollComponent": "SECU",
"CO_IdOfASecUsedAsColl": "FR0000131105",
"RU_ValueOfReusedColl": "2000000",
"RU_EstimatedReuseOfColl": "400000",
"RU_ReusedCollCcy": "EUR"
},
{
"CO_TypeOfCollComponent": "SECU",
"CO_IdOfASecUsedAsColl": "FR0000131106",
"RU_ValueOfReusedColl": "1500000",
"RU_EstimatedReuseOfColl": "1000000",
"RU_ReusedCollCcy": "EUR"
},
{
"CO_TypeOfCollComponent": "CASH",
"RU_ReinvestmentRate": "1.003",
"RU_TypeOfReinvestedCashInvstmnt": "MMFT",
"RU_ReinvestedCashAmt": "150000000",
"RU_ReinvestedCashCcy": "USD"
},
{
"CO_TypeOfCollComponent": "CASH",
"RU_ReinvestmentRate": "0.05",
"RU_TypeOfReinvestedCashInvstmnt": "REPM",
"RU_ReinvestedCashAmt": "200000000",
"RU_ReinvestedCashCcy": "EUR"
}
],
"FndngSrce": [
{
"RU_FundingSources": "OTHR",
"RU_MarketValueOfTheFundingSources": "12000000",
"RU_FundingSourcesCcy": "USD"
},
{
"RU_FundingSources": "BSHS",
"RU_MarketValueOfTheFundingSources": "150000000",
"RU_FundingSourcesCcy": "EUR"
}
],
"UsrDfnd": {
"IM_UserDefined1": "Test Data"
}
}
]
}
这是我目前编写的当前 Jolt 规范(已编辑):
[
{
"operation": "shift",
"spec": {
"Hdr": {
"*": "header.&"
},
"Data": {
"*": {
"*": "data.&",
"Clltrl": {
"*": {
"*": "data.&"
},
"UsrDfnd": {
"*": "data.&"
}
}
}
}
}
}
]
而变换后的输出:
{
"header" : {
"DataSupplier" : "BANK19000001",
"FeedType" : "Reuse",
"SchemaVersion" : "05.00",
"SeqNo" : "1",
"DateProduced" : "2019-09-30T11:44:12Z",
"RecordCount" : 1
},
"body" : {
"CO_TypeOfCollComponent" : [ "SECU", "SECU", "SECU", "CASH", "CASH" ],
"CO_IdOfASecUsedAsColl" : [ "FR0000131104", "FR0000131105", "FR0000131106" ],
"RU_ValueOfReusedColl" : [ "1000000", "2000000", "1500000" ],
"RU_EstimatedReuseOfColl" : [ "500000", "400000", "1000000" ],
"RU_ReusedCollCcy" : [ "EUR", "EUR", "EUR" ],
"RU_ReinvestmentRate" : [ "1.003", "0.05" ],
"RU_TypeOfReinvestedCashInvstmnt" : [ "MMFT", "REPM" ],
"RU_ReinvestedCashAmt" : [ "150000000", "200000000" ],
"RU_ReinvestedCashCcy" : [ "USD", "EUR" ],
"RU_FundingSources" : [ "OTHR", "BSHS" ],
"RU_MarketValueOfTheFundingSources" : [ "12000000", "150000000" ],
"RU_FundingSourcesCcy" : [ "USD", "EUR" ],
"Test Data" : null
}
}
这真的离想要的结果很近了。但是,它缺少输入的 "Data" 部分中的一些数据。我确实尝试了所有可能的组合,并尝试在网上搜索答案,但无济于事。
期望的Json输出:
{
"header" : {
"DataSupplier" : "BANK19000001",
"FeedType" : "Reuse",
"SchemaVersion" : "05.00",
"SeqNo" : "1",
"DateProduced" : "2019-09-30T11:44:12Z",
"RecordCount" : 1
},
"body" : {
"IM_SubmitterID" : "BANK19000001",
"IM_ParticipantID" : "BANK19000001",
"IM_AsOfDateTime" : "2019-09-30T11:44:12Z",
"IM_RepCpCodeType" : "LEI",
"CP_RepCp" : "549300LW9VUUMJV5HC31",
"CO_ActionType" : "Normal",
"CP_EntResponsibleForRep" : "549300LW9VUUMJV5HC31",
"LN_EventDate" : "2019-09-30",
"CO_TypeOfCollComponent" : [ "SECU", "SECU", "SECU", "CASH", "CASH" ],
"CO_IdOfASecUsedAsColl" : [ "FR0000131104", "FR0000131105", "FR0000131106" ],
"RU_ValueOfReusedColl" : [ "1000000", "2000000", "1500000" ],
"RU_EstimatedReuseOfColl" : [ "500000", "400000", "1000000" ],
"RU_ReusedCollCcy" : [ "EUR", "EUR", "EUR" ],
"RU_ReinvestmentRate" : [ "1.003", "0.05" ],
"RU_TypeOfReinvestedCashInvstmnt" : [ "MMFT", "REPM" ],
"RU_ReinvestedCashAmt" : [ "150000000", "200000000" ],
"RU_ReinvestedCashCcy" : [ "USD", "EUR" ],
"RU_FundingSources" : [ "OTHR", "BSHS" ],
"RU_MarketValueOfTheFundingSources" : [ "12000000", "150000000" ],
"RU_FundingSourcesCcy" : [ "USD", "EUR" ],
"IM_UserDefined1" : "Test Data"
}
}
有人可以帮我修改我的 Jolt 规格以获得所需的结果。
非常感谢任何帮助。
由于您没有提供输入数据的软拷贝,我无法使用您自己的数据进行测试。但是,我编造了以下逻辑等价物。假设我们有输入:
{
"hdr": {
"a": "a"
},
"dta": {
"b": "b",
"c": [
{
"d": "d1",
"e": "e1"
},
{
"d": "d2",
"e": "e2"
}
]
}
}
我们想要的输出是:
{
"header" : {
"a" : "a"
},
"data" : {
"b" : "b",
"d" : [ "d1", "d2" ],
"e" : [ "e1", "e2" ]
}
}
那么以下可以用作 Jolt 规格:
[
{
"operation": "shift",
"spec": {
"hdr": {
"*": "header.&"
},
"dta": {
"*": "data.&",
"c": {
"*": {
"*": "data.&"
}
}
}
}
}
]
我和这个很亲近。但是,恐怕输出并不是我想要的。有人可以帮我更正我的 Jolt Spec 以获得我正在寻找的确切转换吗?我真的为此绞尽脑汁,非常感谢最后一点帮助。
所以目前我看起来像这样:
{
"Hdr": {
"DataSupplier": "BANK19000001",
"FeedType": "Reuse",
"SchemaVersion": "05.00",
"SeqNo": "1",
"DateProduced": "2019-09-30T11:44:12Z",
"RecordCount": 1
},
"Data": [
{
"IM_SubmitterID": "BANK19000001",
"IM_ParticipantID": "BANK19000001",
"IM_AsOfDateTime": "2019-09-30T11:44:12Z",
"IM_RepCpCodeType": "LEI",
"CP_RepCp": "549300LW9VUUMJV5HC31",
"CO_ActionType": "Normal",
"CP_EntResponsibleForRep": "549300LW9VUUMJV5HC31",
"LN_EventDate": "2019-09-30",
"Clltrl": [
{
"CO_TypeOfCollComponent": "SECU",
"CO_IdOfASecUsedAsColl": "FR0000131104",
"RU_ValueOfReusedColl": "1000000",
"RU_EstimatedReuseOfColl": "500000",
"RU_ReusedCollCcy": "EUR"
},
{
"CO_TypeOfCollComponent": "SECU",
"CO_IdOfASecUsedAsColl": "FR0000131105",
"RU_ValueOfReusedColl": "2000000",
"RU_EstimatedReuseOfColl": "400000",
"RU_ReusedCollCcy": "EUR"
},
{
"CO_TypeOfCollComponent": "SECU",
"CO_IdOfASecUsedAsColl": "FR0000131106",
"RU_ValueOfReusedColl": "1500000",
"RU_EstimatedReuseOfColl": "1000000",
"RU_ReusedCollCcy": "EUR"
},
{
"CO_TypeOfCollComponent": "CASH",
"RU_ReinvestmentRate": "1.003",
"RU_TypeOfReinvestedCashInvstmnt": "MMFT",
"RU_ReinvestedCashAmt": "150000000",
"RU_ReinvestedCashCcy": "USD"
},
{
"CO_TypeOfCollComponent": "CASH",
"RU_ReinvestmentRate": "0.05",
"RU_TypeOfReinvestedCashInvstmnt": "REPM",
"RU_ReinvestedCashAmt": "200000000",
"RU_ReinvestedCashCcy": "EUR"
}
],
"FndngSrce": [
{
"RU_FundingSources": "OTHR",
"RU_MarketValueOfTheFundingSources": "12000000",
"RU_FundingSourcesCcy": "USD"
},
{
"RU_FundingSources": "BSHS",
"RU_MarketValueOfTheFundingSources": "150000000",
"RU_FundingSourcesCcy": "EUR"
}
],
"UsrDfnd": {
"IM_UserDefined1": "Test Data"
}
}
]
}
这是我目前编写的当前 Jolt 规范(已编辑):
[
{
"operation": "shift",
"spec": {
"Hdr": {
"*": "header.&"
},
"Data": {
"*": {
"*": "data.&",
"Clltrl": {
"*": {
"*": "data.&"
},
"UsrDfnd": {
"*": "data.&"
}
}
}
}
}
}
]
而变换后的输出:
{
"header" : {
"DataSupplier" : "BANK19000001",
"FeedType" : "Reuse",
"SchemaVersion" : "05.00",
"SeqNo" : "1",
"DateProduced" : "2019-09-30T11:44:12Z",
"RecordCount" : 1
},
"body" : {
"CO_TypeOfCollComponent" : [ "SECU", "SECU", "SECU", "CASH", "CASH" ],
"CO_IdOfASecUsedAsColl" : [ "FR0000131104", "FR0000131105", "FR0000131106" ],
"RU_ValueOfReusedColl" : [ "1000000", "2000000", "1500000" ],
"RU_EstimatedReuseOfColl" : [ "500000", "400000", "1000000" ],
"RU_ReusedCollCcy" : [ "EUR", "EUR", "EUR" ],
"RU_ReinvestmentRate" : [ "1.003", "0.05" ],
"RU_TypeOfReinvestedCashInvstmnt" : [ "MMFT", "REPM" ],
"RU_ReinvestedCashAmt" : [ "150000000", "200000000" ],
"RU_ReinvestedCashCcy" : [ "USD", "EUR" ],
"RU_FundingSources" : [ "OTHR", "BSHS" ],
"RU_MarketValueOfTheFundingSources" : [ "12000000", "150000000" ],
"RU_FundingSourcesCcy" : [ "USD", "EUR" ],
"Test Data" : null
}
}
这真的离想要的结果很近了。但是,它缺少输入的 "Data" 部分中的一些数据。我确实尝试了所有可能的组合,并尝试在网上搜索答案,但无济于事。
期望的Json输出:
{
"header" : {
"DataSupplier" : "BANK19000001",
"FeedType" : "Reuse",
"SchemaVersion" : "05.00",
"SeqNo" : "1",
"DateProduced" : "2019-09-30T11:44:12Z",
"RecordCount" : 1
},
"body" : {
"IM_SubmitterID" : "BANK19000001",
"IM_ParticipantID" : "BANK19000001",
"IM_AsOfDateTime" : "2019-09-30T11:44:12Z",
"IM_RepCpCodeType" : "LEI",
"CP_RepCp" : "549300LW9VUUMJV5HC31",
"CO_ActionType" : "Normal",
"CP_EntResponsibleForRep" : "549300LW9VUUMJV5HC31",
"LN_EventDate" : "2019-09-30",
"CO_TypeOfCollComponent" : [ "SECU", "SECU", "SECU", "CASH", "CASH" ],
"CO_IdOfASecUsedAsColl" : [ "FR0000131104", "FR0000131105", "FR0000131106" ],
"RU_ValueOfReusedColl" : [ "1000000", "2000000", "1500000" ],
"RU_EstimatedReuseOfColl" : [ "500000", "400000", "1000000" ],
"RU_ReusedCollCcy" : [ "EUR", "EUR", "EUR" ],
"RU_ReinvestmentRate" : [ "1.003", "0.05" ],
"RU_TypeOfReinvestedCashInvstmnt" : [ "MMFT", "REPM" ],
"RU_ReinvestedCashAmt" : [ "150000000", "200000000" ],
"RU_ReinvestedCashCcy" : [ "USD", "EUR" ],
"RU_FundingSources" : [ "OTHR", "BSHS" ],
"RU_MarketValueOfTheFundingSources" : [ "12000000", "150000000" ],
"RU_FundingSourcesCcy" : [ "USD", "EUR" ],
"IM_UserDefined1" : "Test Data"
}
}
有人可以帮我修改我的 Jolt 规格以获得所需的结果。
非常感谢任何帮助。
由于您没有提供输入数据的软拷贝,我无法使用您自己的数据进行测试。但是,我编造了以下逻辑等价物。假设我们有输入:
{
"hdr": {
"a": "a"
},
"dta": {
"b": "b",
"c": [
{
"d": "d1",
"e": "e1"
},
{
"d": "d2",
"e": "e2"
}
]
}
}
我们想要的输出是:
{
"header" : {
"a" : "a"
},
"data" : {
"b" : "b",
"d" : [ "d1", "d2" ],
"e" : [ "e1", "e2" ]
}
}
那么以下可以用作 Jolt 规格:
[
{
"operation": "shift",
"spec": {
"hdr": {
"*": "header.&"
},
"dta": {
"*": "data.&",
"c": {
"*": {
"*": "data.&"
}
}
}
}
}
]