Using:
console.log("First Item Author: "+myjson.value.items.0.author);
I get the following error:
Object Uncaught SyntaxError: Unexpected number
Trying to access the following object:
Using:
console.log("First Item Author: "+myjson.value.items.0.author);
I get the following error:
Object Uncaught SyntaxError: Unexpected number
Trying to access the following object:
Share Improve this question edited Aug 27, 2013 at 17:21 Felix Kling 818k181 gold badges1.1k silver badges1.2k bronze badges asked Aug 27, 2013 at 17:05 Hydra IOHydra IO 1,5611 gold badge13 silver badges29 bronze badges 3- 1 That's Javascript. It has nothing to do with jQuery. – SLaks Commented Aug 27, 2013 at 17:11
- It has nothing to do with JSON either. – Felix Kling Commented Aug 27, 2013 at 17:21
- possible duplicate of Access / process (nested) objects, arrays or JSON – Felix Kling Commented Aug 27, 2013 at 17:21
2 Answers
Reset to default 40
is not a valid identifier and cannot be used as a direct property name.
Instead, use array notation:
items[0].author
0
is not a valid identifier name. Use bracket notation instead of dot notation:
console.log("First Item Author: " + myjson.value.items[0].author);