Renaming nested fields

I feel I'm getting closer,

I've found on another post a way to do it but somehow it's not working for me.

I used the filter ruby plugin like this

filter {
	if([field1][nestedField]){
		ruby {
			code => "
				event.get('[field1][nestedField]').each { |k|
					k['camelCase1'] = k['lowercase1']
					k['camelCase2'] = k['lowercase2']
					k.delete('lowercase1')
					k.delete('lowercase2')
					logger.info('for each k', 'value' => k)
				}
				logger.info('full array' , 'value' => event.get('[field1][nestedField]'))
			"
		}
	}
}

The thing is when I print "k" in the logger it's exactly has I want it to be but when I print the whole array nothing has changed.

Am I missing some kind of set?