Manipulating data in logstash

This helped: How can I create new field inside an array of obejcts?

    ruby {
        code => '
            entities = event.get("Entities")
            if entities.is_a? Array
                entities.each_index { |i|
                    location = {}
                    location["lat"] = entities[i]["Entity"]["World Location"]["Latitude"]
                    location["lon"] = entities[i]["Entity"]["World Location"]["Longitude"]
                    entities[i]["Entity"]["location"] = location
                }
                event.set("Entities", entities)
            end
        '
    }