0

I am new to JOLT. I have 2 different set of input json of same structure except one object inside differs based on the decider value like below.

Eg: Input json 1

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

Eg: Input json 2

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

output expectation if decider : 1

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

output expectation if decider : 2

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

I want to write a generic single conditional jolt spec which based on "decider" value output should be generated. Is there a way to write a conditional statement inside spec file....??

Balaji Kannan
  • 407
  • 6
  • 24

1 Answers1

0

See https://github.com/bazaarvoice/jolt/issues/231

Same question was ask there.

Milo S
  • 4,466
  • 1
  • 19
  • 22