Kibana painless scripted fields. Loop on array of objects

Thanks Peter, i am able to get it worked. I see the desired output now.Have a good one