Please help me access nested array

To access the array, you need to use array index. Instead of using @messages_test = options[‘Messages’][‘IBMessageID’].to_s you need to use, to access to first element the arrayoptions[‘Messages’] array, below code @messages_test = options[‘Messages’][0][‘IBMessageID’].to_s You can iterate the array, if you wish, by using options[‘Messages’] each do |item| puts item[“IBMessageID”] # for illustration end