Sam One
Sam One

Reputation: 19

Fetch JSON data from an array within an array

Lets say I have a URL that brings out this JSON object.

How do I fetch Albertson?

{
  "ancestor" : [
    {
      "father" : [
         {
           "long_name" : "Albertson",
           "short_name" : "Roger",
           "types" : [ "surname" ]
         }
       ]
     }
  ],
}

Is it ancestor[0][0].long_name?

Upvotes: 1

Views: 53

Answers (1)

Shrinivas Pai
Shrinivas Pai

Reputation: 7711

You can fetch the data using

object.ancestor[0].father[0].long_name

You can also refer: http://www.json.com/#object-with-nested-array-and-object

Upvotes: 1

Related Questions