Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
removing nulls from jolt array
Labels:
- Labels:
-
Apache Hadoop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Expert Contributor
Created ‎06-27-2020 11:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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
