What I'm trying to achieve is I have input like
"jsonBody": {
"measurements": [
{
"value": 0,
"statistic": "VALUE"
},
{
"value": 1,
"statistic": "VALUE2"
},
]
}
and I am trying to convert it into something like this
"jsonBody": {
"measurements"
{
"VALUE":0,
"VALUE2":1
}
}
So far i Have tried to do this
filter{
ruby{
code => 'b= event.get("[response][jsonBody][measurements]")
Array(b).each{|kv| event.set(kv["statistic"], kv["value"])}'
}
}
and
filter{
ruby{
code => 'b= event.get("[response][jsonBody][measurements]")
b.each{|kv| event.set(kv["statistic"], kv["value"])}'
}
}
Both of these methods don't seem to work very well.
What am I missing?