can someone help me please with the next problem: I need to remove from payload objects based on the next condition: if some specific key is null, I need to remove the whole object, which contains this key and value from payload. example:
{
"issues":[
{
"key":"13996",
"fields":{
"customfield_13100":null,
"customfield_15400":null,
"customfield_13102":null,
"customfield_13104":null,
"customfield_12809":"",
"lastViewed":null,
"customfield_12000":[
"870CA25F"
]
}
},
{
"key":"13996",
"fields":{
"customfield_13100":null,
"customfield_15400":null,
"customfield_13102":null,
"customfield_13104":null,
"customfield_12809":"",
"lastViewed":null,
"customfield_12000":null
}
},
{
"key":"13996",
"fields":{
"customfield_13100":null,
"customfield_15400":null,
"customfield_13102":null,
"customfield_13104":null,
"customfield_12809":"",
"lastViewed":null,
"customfield_12000":[
"870CA25F"
]
}
}
]
}
I was trying filterObject in various variations but no luck
let's say condition is: if "customfield_12000" == null, the whole object must be removed. expected output example: `
{
"issues":[
{
"key":"13996",
"fields":{
"customfield_13100":null,
"customfield_15400":null,
"customfield_13102":null,
"customfield_13104":null,
"customfield_12809":"",
"lastViewed":null,
"customfield_12000":[
"870CA25F"
]
}
},
{
"key":"13996",
"fields":{
"customfield_13100":null,
"customfield_15400":null,
"customfield_13102":null,
"customfield_13104":null,
"customfield_12809":"",
"lastViewed":null,
"customfield_12000":[
"870CA25F"
]
}
}
]
}
If I understand correctly you want to remove the item from the
issueslist if one specific key is null. Since in the example provided that key is in thefieldsobject I am assuming the conditions are all similar.filterObject() is not appropriate because you are filtering items from an array, not key-values inside the object. filter() is the right function to filter items in an array.
I used the
updateoperator and created a function to encapsulate the filter() call. The dynamic selector lets us parametrize the keys used: