使用jolt变换并将平面json转换为复杂的嵌套json数组

时间:2019-02-09 02:22:00

标签: arrays json multidimensional-array jolt

我有一个关于使用jolt将平面json转换为嵌套json的问题。我很不高兴,这是我的投入

{
 "id": "LIKKI MOSORU",
 "aff_id": "WOOD",
 "aff_name": "WOOD-LOVE",
 "aff_desc": "WOOD INC.",
 "aff_corrltn_name": "MARVEL MEMBERSHIP",         
 "aff_corrltn_id": "8999938",
 "affil_trans_id": "222222",
 "misc_aff_dtl_name": "MBR-FIRST-NAME",
 "misc_aff_dtl_value" :"KKKKKLYYYY",
 "oper_id": "AP",
 "create_timestamp":"2018-10-16-04:00",
 "update_timestamp": "2018-10-17-04:00",
 "active_rcrd": "Y"
 }

我写了震动规范,但没有得到想要的输出

    [
      {
        "operation": "shift",
        "spec": {
          "misc_aff_dtl_*": "misc_aff_dtl.&(0,1)",
          "aff_corrltn_*": "aff_corrltn.&(0,0)",
          "aff_*": "aff.&(0,0)",
          "rewards_id": "rewards_id",
          "oper_id": "oper_id",
          "create_timestamp": "create_timestamp",
          "update_timestamp": "update_timestamp",
          "active_rcrd": "active_rcrd"
        }
    }
    ]

我的预期输出是:

    {
    "rewards_id": "Jeannine Rosario",
    "aff": [
        {        
    "aff_id": "WOOD",
    "aff_name": "WOOD-LOVE",
    "aff_desc": "WOOD INC.",
    "aff_corrltn": [
    {        
        "aff_corrltn_name": "MARVEL MEMBERSHIP",         
        "aff_corrltn_id": "8999938",
        "affil_trans_id": "222222",
        "misc_aff_dtl": [        
            {  
                "name":"MBR-FIRST-NAME",
                "value":"DANJALKSA"
            }
          ] 
    }           
    ],
     "oper_id": "AP",
     "create_timestamp":"2018-10-16-04:00",
     "update_timestamp": "2018-10-17-04:00",
     "active_rcrd": "Y"
     }
     ]
    }

任何一个震动专家都可以帮助我获得所需的输出。我应该在摇动中使用多个转换,还是可以在一个摇动变压器中获得所需的输出?

1 个答案:

答案 0 :(得分:1)

使用Iterable添加数组将具有所需的效果:

[0]