{
"field": "@timestamp",
"value": "2024-08-20 23:00:13.426"
}
{
"field": "@message",
"value": "Started-1"
}
{
"field": "@timestamp",
"value": "2024-08-20 23:00:13.427"
}
{
"field": "@message",
"value": "Started-2"
}
Edited to show that the JSONs are repeating block
I have JSONs above which need to be merged as below. Please help
[{
"@timestamp": "2024-08-20 23:00:13.426",
"@message": "Started-1"
},
{
"@timestamp": "2024-08-20 23:00:13.427",
"@message": "Started-2"
}]
2
Answers
You can use the
from_entries
function, which does exactly what you want, but it requires the future key’s name in a field calledkey
orname
. Thus, first transform the objects to meet this requirement (thevalue
field can stay as-is):Demo