Bazaarvoice Jolt Generic Spec,适用于多种输入JSON

时间:2016-07-12 12:27:35

标签: jolt

我是JOLT的新手。我有两组不同的相同结构的输入json,除了一个对象里面根据如下的决定值而不同。

例如:输入json 1

{
    "input": {
        "decider": 1,
        "object1": {
            "object1Info": 1
                        "obj1SpecificObj2" : {
                obj2info : "data"
            }
        },
        "doc": {
            "docId": "DOC100"
        }
    }
}

例如:输入json 2

{
    "input": {
        "decider": 2,
        "object2": {
            "object2Info": 2
                        "obj2SpecificObj3" : {
                "obj3info1" : "data1",
                "obj3info2" : "data2",
                                "other" : {
                                       "otherData" : "data3"
                                }
            }
        },
        "doc": {
            "docId": "DOC100"
        }
    }
}

如果决策者输出期望值:1

{
    "out" : {
        "object"" : {
            "info"" : 1
            "subObject" : {
                "subInfo" : "data"
            }
        },
        "doc": {
            "docId": "DOC100"
        }
    }
}

如果决策者输出期望值:2

{
    "out" : {
        "object"" : {
            "info"" : 1
            "subObject" : {
                "subInfo1" : "data1",
                "subInfo2" : "data2",
                                "other" : {
                                       "otherData" : "data3"
                                }
            }
        },
        "doc": {
            "docId": "DOC100"
        }
    }
}

我想写一个基于“decider”值输出的通用单条件jolt规范应该生成。有没有办法在spec文件中编写条件语句.... ??

1 个答案:

答案 0 :(得分:0)

请参阅https://github.com/bazaarvoice/jolt/issues/231

同样的问题在那里问。