Convert a Json array of object ([{},{},{}] - this format) to {[],[],[]}


(Panda) #1

Hi

I have a Json I/P which looks like:

{
	"data": { 
		"arrayField" :[ {"id" : 7,"data" : "a"},{"id" : 3,"data" : "b"}],
		"field1" : "value1"	
	}
}

Where arrayField can contain any number of element.

I want to access the arrayField inside elasticsearch script which needs a format like {["id" : 7,"data" : "a"],["id" : 3,"data" : "b"]}.

How can I do this conversion ?


#2

Hello,

you can use split filter,
Ex:-
filter {
split {
field => "arrayField"
}
}