Support Questions
Find answers, ask questions, and share your expertise

removing nulls from jolt array

removing nulls from jolt array

New Contributor

Json Input:

{
"value_schema_id": "GBM_KF_DH_ClientFilter",
"system_code": "LogMessage",
"event_type": "PROCESSOR",
"metric_name": "ERROR",
"metric_id": "1",
"global_person_profile_id": "2",
"create_ts": "3"
}

JOLT Specification:

[
{
"operation": "shift",
"spec": {
"value_schema_id": "value_schema_id",
"system_code": "records[1].value.system_code",
"event_type": "records[1].value.event_type",
"metric_name": "records[1].value.event_detail.metric_name",
"metric_id": "records[1].value.event_detail.metric_id",
"global_person_profile_id": "records[1].value.event_detail.global_person_profile_id",
"create_ts": "records[1].value.event_detail.create_ts"
}
}
]

Json Output

{
"value_schema_id" : "GBM_KF_DH_ClientFilter",
"records" : [ null, {
"value" : {
"system_code" : "LogMessage",
"event_type" : "PROCESSOR",
"event_detail" : {
"metric_name" : "ERROR",
"metric_id" : "1",
"global_person_profile_id" : "2",
"create_ts" : "3"
}
}
} ]
}

 

Can you please help me to take out nulls from the output-json. 

1 REPLY 1
Highlighted

Re: removing nulls from jolt array

Contributor

@tsvk4u 
If you replace records[1] with records[0]. You won't be getting null as the first value inside records array. But, if you have done it deliberately and you want to remove the null values, look at the following spec:

[
{
"operation": "shift",
"spec": {
"records": {
"*": {
"*": "records[]"
}
},
"*": "&"
}
}
]

Note: This spec is to be applied after you have applied your spec

Don't have an account?