0

lets say I have an array that looks like this:

var arr = [{
    "id": 1,
    "content": "[{\"number\":1,\"name\":\"Image\",\"description\":\"\",\"fields\":\"[{\\\"number\\\":1,\\\"text\\\":\\\"Image Test\\\",\\\"description\\\":\\\"\\\",\\\"responseType\\\":\\\"Image\\\",\\\"options\\\":\\\"[]\\\"},{\\\"number\\\":2,\\\"text\\\":\\\"test2\\\",\\\"description\\\":\\\"\\\",\\\"responseType\\\":\\\"Text\\\",\\\"options\\\":\\\"[]\\\"}]\"}]"

}];

I'm trying to access the content which is a nested array.

Im doing this:

var myArray = JSON.parse(arr.content);

console.log(myArray);

But this always returns this error:

SyntaxError: JSON Parse error: Unexpected identifier "undefined"

what I'm I doing wrong here?

drago
  • 1,148
  • 2
  • 16
  • 35

1 Answers1

2
myArray = JSON.parse(arr[0].content);
Cyrille Pontvieux
  • 2,356
  • 1
  • 21
  • 29