Parsing array of json objects

Hello ,

I am new to logstash and would like to parse the below json file and add three seperate fields header1 and header2 and header3. Any suggestion on how to do it

{
"name": "abc",
"headers": [
{
"header1": "value1"
},
{
"header2": "value2"
},
{
"header3": "value3"
}
]
}

You could try

    ruby {
        code => '
            h = event.remove("headers")
            if h
                h.each { |x|
                    x.each { |k, v|
                        event.set(k, v)
                    }
                }
            end
        '
    }

Add error checking as needed.