Ruby Hash of arrays iteration

I’m new to Ruby and i have a problem.

I make a RestClient.get on an url and i make a JSON parse on it.

response= RestClient.get ‘

response looks like this:
{“tag”=>[“one”, “two”, “three”], “name”=>“example”}

and i would like to have an array like this::

I can print all tags or names but not together, if someone can help me :slight_smile:

So, assuming you have your response in variable response, you can do this:

response = {"tag"=>["one", "two", "three"], "name"=>"example"}
def get_formatted_response(response)
    name = response["name"]
    tags = response["tag"]
    new_list = []
    tags.each do |tag|
        new_list << name + "-" + tag
    return new_list
print get_formatted_response(response)

Run it here

Hope it helps! :smiley: