Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

JOLT Spec for supporting the input json

avatar
New Contributor

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"
} ]
}