Skip to content
Advertisement

Null Check in Jolt while converting string to integer For an Object

I am doing conversion of string to integer/double in my jolt spec. If elements does not come in request, then empty object is coming in response. Instead I do not want to pass that object itself as its empty.

Input Request Working:

JavaScript

Jolt Spec:

JavaScript

Output if tag is there in request:

JavaScript

But when input request is like below where I do not get second tag:

JavaScript

Current Output:

JavaScript

Getting second object as empty

JavaScript

Expected Output:

JavaScript

Please help to fix this issue.

Advertisement

Answer

Rethink in a dynamical manner by using ampersand placeholders such as

JavaScript

the suffixed integers for those ampersands represents the level to go up to grab the desired value such as &1 and &2 stand for data, & without integer suffixes represent the value from the current level.

“*” wildcard represents the rest of the elements, other than first in this case(you might have third, fourth … as other elements to be formatted like the second)

first case : enter image description here

second case : enter image description here

Edit : For the current case which’s mentioned within the edit in order to get

JavaScript

from the input

JavaScript

which had a new entry “secondNew”: “3”, you’ll need to write each key explicitly within the spec such as

JavaScript

in order to combine the rest of the elements under common object.

Advertisement