r/learnruby • • Aug 15 '16

Parsing nested data

Hi, so I'm fairly new to Ruby and I had a quick question about parsing some data I'm pulling from an API. The data looks like this:

{
"extractorData" : {
"url" : "hid_this_url",
"resourceId" : "and_this_id",
"data" : [ {
  "group" : [ {
    "score" : [ {
      "text" : "10"
    } ]
  } ]
} ]
}

I'm using JSON.parse and I was wondering if there a quick method I could use so that I could extract the value "10" in this example and assign it to a variable? I appreciate any and all help!

1 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Aug 16 '16

Reading your answer even helped solve another issue I was having. Thank you so much!