GreenBee
GreenBee

Reputation: 3101

Parsing Google Fusiontable API returned JSON in Javascript

Can someone please shed some light on how to parse this JSON object returned by Google Fusion Tables query APIs in Javascript?

{
 "kind": "fusiontables#sqlresponse",
 "columns": [
  "Name",
  "Function",
  "Culprit"
 ],
 "rows": [
  [
   "Bha3",
   "9, 41",
   "1"
  ],
  [
   "Bha23",
   "7, 26, 56, 57",
   "1"
  ]
 ]
}

I want to extract values Bha3 and Bha23 from this object. But there are no names in "columns" and "rows" objects. So essentially, this is not a JSON object(?) How do I get individual values from rows?

Upvotes: 0

Views: 1041

Answers (1)

PSL
PSL

Reputation: 123739

You can access those values by looking up the 2-d array rows

data.rows[0][0]; //Bha3
data.rows[1][0]; //Bha23

Where data is your object.

Demo

And with simple for loop you can access all values like this

Upvotes: 1

Related Questions