Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

JOLT spec to decide the value based on content

Solved Go to solution

JOLT spec to decide the value based on content

Rising Star

I am enriching my request payload with the payload attribute 'http.headers.orgId' and its working fine.

SPEC:

[{ "operation": "default",

"spec": {

"*": { "orgId": "${http.headers.orgId}" }

}

}]

INPUT :

{ "drivewiseDeviceData": { "imei": "sampleimei", "tripId": "3d9df81a-1828-40eb-940e-d2434eb5f50f", "sumVer": null, "payloadType": "Binary", "packetInfo": "", "payloadData": "g1bjSWX", "recordinfo": null, "sequenceNum": null, "timeStamp": "2017-05-26T12:07:29.968Z" } }

OUTPUT:

{ "drivewiseDeviceData": { "imei": "sampleimei", "tripId": "3d9df81a-1828-40eb-940e-d2434eb5f50f", "sumVer": null, "payloadType": "Binary", "packetInfo": "", "payloadData": "g1bjSWX", "recordinfo": null, "sequenceNum": null, "timeStamp": "2017-05-26T12:07:29.968Z", "orgId": "Sample Org Name Here" } }

.........................................................................................................................................

Now scenarios is I may get header attribute as 'http.headers.OrgID' or 'http.headers.orgId',

So is there any way to handle both scenarios in my JOLT spec?

If 'http.headers.orgId' value is null/empty/attribute-not-present then I should use 'http.headers.OrgID' for enrich.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: JOLT spec to decide the value based on content

Super Guru

You should be able to use UpdateAttribute with ExpressionLanguage (probably the ifElse() function along with isNull()) in order to set http.headers.orgId to http.headers.OrgID if it is not already populated. Then you can keep the JOLT spec as-is.

View solution in original post

1 REPLY 1
Highlighted

Re: JOLT spec to decide the value based on content

Super Guru

You should be able to use UpdateAttribute with ExpressionLanguage (probably the ifElse() function along with isNull()) in order to set http.headers.orgId to http.headers.OrgID if it is not already populated. Then you can keep the JOLT spec as-is.

View solution in original post

Don't have an account?
Coming from Hortonworks? Activate your account here