Forum Discussion

kishore505's avatar
kishore505
New Contributor
2 years ago

How to disable specific key using Mapper snap

I've a problem with disabling a specific key in a room[] array. I've tried many ways but still haven't found any solution.

am trying to disable in area key in room[] array.

My Inputs

{
"house": {
"room": [ 
{
"name": "Bedroom",
"area": 10
}, 
{
"name": "Bathroom",
"area": 9
}, 
{
"name": "Kitchen",
"area": 12
}
],
"garden": {
"area": 150
}
}
}
 
And my desired output is something like this:
{
"house": {
"room": [{
"name": "Bedroom"
},
{
"name": "Bathroom"
},
{
"name": "Kitchen"
}
],
"garden": {
"area": 150
}
}
}

2 Replies

  • This is actually a pretty good use case for our Structure Snap.  It allows for these kinds of operations to be a bit more simplified, you can achieve this using the Structure snap with the following settings:

    In this case, it's key that pass through is set to "yes" as it will then allow you to modify the input document in-place, when you select "delete" you don't need to set a target path.  Doing this through a mapper might be a bit more difficult to achieve because you'd effectively have to re-build the house.room array.

  • kishore505 - another option is to use the Mapping Root in the Mapper snap to affect only that sub-element of the incoming document.  For example, assuming your input, configure a Mapper as follows:

    Which gives the following output: