Remove dynamic nested field in JSON

Hi ,

I have an input (JSON) like below:

// Sample input JSON doc

"TestCases": {
  "0": {
    "Verdict": "PASS",
    "tcId": 0,
    "NoOfFail": 0
  },
  "1": {
  }

Where number of test cases is not static and I want to remove field "NoOfFail" of each test case. I guess I cant use mutate as remove_filed requires a static filed value.
Can somebody help here.

Thanks,
Mahipal

I have tried many stuff including Ruby filter like below

ruby {
code => "
if event.get('[doc][ExecutionData][TestCases]') != nil
event.set('[doc][ExecutionData][TestCases]',
event.get('[doc][ExecutionData][TestCases]').each_value { |url|
event.remove(url['Verdict'])
# event.get('[doc][ExecutionData][TestCases]').delete(url)
# url.delete('0')
}
);
end
"
}

But nothing works, Please help.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.