Iterate over Object keys

painless

#1

I have a painless script inside of an update query.
The Script receives a parameter containing an array with different hashes like this:

{
	"fields": [
		{"keyA": 1, "keyB": 2, "keyC": "something"},
		{"keyD": "anything", "keyE": 2},
		{"name": 1, "age": 2, "city": "London"}
	]
}

I need to iterate over the keys of each of these objects in painless.
Therefore I need to get the keys that the object has.

for (int i=0; i<params.fields.length; i++) {
	Object obj = params.fields[i];
	
	// iterate over object keys
	for (...) {
		// do something with the object key
	}
}

In Javascript my inner loop would look something like this:

for (let [key, value] of Object.entries(obj)) {
	// do something with the object key
}

But how can this be done in painless?