使用JOLT JSON库转换Collection中的每个JSON对象

时间:2018-10-04 03:47:39

标签: jolt

输入JSON集合:

    {
    "Collection": 
      [
        { 
          "A_1" : "xyz",
          "B_1" : "abc"
          "C_1" : "qwe",
          "A_2" : "dfg",
          "B_2" : "tyy"
          "C_2" : "uyt",
          "actors" : "aaa,bbb,ccc,ddd",
          "players" : "www,fff,eee,yyyy,tttt,iiii" 
        },
        { 
          "A_1" : "bcd",
          "B_1" : "hij"
          "C_1" : "lmn",
          "A_2" : "opq",
          "B_2" : "rst"
          "C_2" : "uvw",
          "actors" : "a1,a2,a3",
          "players" : "123,777,555,8999" 
        },
    {..},{..},{..},{..},{..},{..},{..},{..} 
      ]
    }

操作:
1)拆分一个字符串并存储为数组

2)将所有重复属性分组为对象数组。

预期产量

    {
      "Collection": 
      [
        {
        "actors"  : [aaa, bbb, ccc, ddd],
        "players" : [www, fff, eee, yyyy, tttt, iiii],
        "ObjName" : [ 
                        { "A" : "xyz" ,
                          "B" : "abc",
                          "C" : "qwe"
                        },
                        { "A" : "dfg" ,
                          "B" : "tyy",
                          "C" : "uyt"
                        }
                    ]
        },
        {
        "actors" :  [a1, a2, a3],
        "players" : [123, 777, 555, 8999],
        "ObjName" : [ 
                        { "A" : "bcd" ,
                          "B" : "hij",
                          "C" : "lmn"
                        },
                        { "A" : "opq" ,
                          "B" : "rst",
                          "C" : "uvw"
                        }
                    ]
        },

    {..},{..},{..},{..},{..},{..},{..},{..}
      ]
    }

创建“ ObjName”用于存储重复的A,B,C数组。

可以让我知道用于将输入格式转换为输出的spec.json吗?

0 个答案:

没有答案