Support Questions

Find answers, ask questions, and share your expertise
Announcements
Now Live: Explore expert insights and technical deep dives on the new Cloudera Community BlogsRead the Announcement

JOLT Spec for supporting the input json

avatar
Visitor

Actually I need to filter the id exist data and non existing data to separate user defined array list. can someone help me with Jolt Specification. someone please help me with the jolt specification to achieve the below results.

 

Input:
          
{
    "data": [
        {
            "name": "a",
            "id": "100"
        },
        {
            "name": "b",
            "id": "101"
        },
        {
            "name": "c"
        }
    ]
}
            
Output:
            
 

  
        {
    "IdExists": [
        {
            "name": "a",
            "id": "100"
        },
        {
            "name": "b"
        }
    ],
    "IdNotExists": [
        {
            "name": "c"
        }
    ]
}
        
1 REPLY 1

avatar
Explorer

jolt specification :

[{
"operation": "shift",
"spec": {
"@": "&",
"data": {
"*": {
"id": {
"@(1)": "idexist.[]"
}}}}}]

output : 

{
"root" : {
"data" : [ {
"name" : "a",
"id" : "100"
}, {
"name" : "b",
"id" : "101"
}, {
"name" : "c"
} ]
},
"idexist" : [ {
"name" : "a",
"id" : "100"
}, {
"name" : "b",
"id" : "101"
} ]
}