所以目前我看到的是这样的:
{
"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
}
}
{
"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"
}
}
任何帮助都是非常感谢的。
由于您没有提供输入数据的软拷贝,我无法用您自己的数据进行测试。然而,我编造了以下逻辑等价。假设我们有以下输入:
{
"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.&"
}
}
}
}
}
]
输入 json : 预期输出: 我想有一个颠簸转换,它可以嵌套很少的田地。
我有一个JSON如下所示: 为什么在输出中看不到Level1、Level2?请有人帮忙,我想看看在输出和输入太相似了。
如何使用jolt转换将平面JSON转换为嵌套JSON?我对JSON和jolt是新手。 输入: 预期输出: 编辑:我想在< code>SubFunds中添加一个新字段,但是新字段不在JSON文件中,它是计算字段,我可以按原样添加示例吗 并重命名字段:
我有一个嵌套的JSON对象,如下所示: 我想将其转换为: 我如何使用JOLT实现这一点?感谢您的参与。
我有json,其中包括多个产品,每个产品有多个不同的细节。使用jolt,我只需要输入json中的几个字段,遵循与输入json几乎相同的结构。我成功地迭代了产品,但是当我试图迭代每个产品变体时,我没有得到想要的输出。 输入. json 这里是Spec.json 我想要的预期输出。 我现在得到的实际输出。
我有一个关于使用jolt将平面json转换成嵌套json的问题。我对jolt很陌生,这是我的意见 我编写了jolt spec,但我没有得到想要的输出 我的预期产出是: 任何震动专家都可以帮助我获得所需的输出。我应该在颠簸中使用多个变换,还是可以在一个震动变压器中获得所需的输出?