-1

I have and API that return an Array of object like the following:

{
  "form_submit.form_submit_id": 7987,
  "form_submit.exported": false,
  "form_submit.updatedAt": "2016-01-18T16:13:16.813Z",
  "form_submit.user.user_id": 14,
  "form_submit.user.name": "Hugo Bismarck",
},

If I use the . on my javascript for example to get the first element

var test = array[0].form_submit.form_submit_id;

get the following error

array[0].form_submit.form_submit_id is undefined

the problem is that the name of the attributes have points, so how can acces to this attributes?

oriaj
  • 768
  • 1
  • 16
  • 33

1 Answers1

1

You can use in this case the bracket notation:

property_name is a string. The string does not have to be a valid identifier; it can have any value, e.g. "1foo", "!bar!", or even " " (a space).

var test = array[0]['form_submit.form_submit_id'];
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392