Normally, we access json object elements using dot notation i.e. var obj = {"key": "value"}; var val = obj.key;
. How do we access the value in case of var obj = {"key-with-hyphens": "value"};
? Do I have to revert to [] i.e. var val = obj['key-with-hyphens'];
?
Asked
Active
Viewed 5,782 times
3

user3607612
- 131
- 1
- 11
-
2Using `obj['key-with-hyphens']` – Rayon Oct 05 '15 at 06:24
-
1Possible duplicate of [Unable to access JSON property with "-" dash](https://stackoverflow.com/questions/13869627/unable-to-access-json-property-with-dash) – JJJ Jun 05 '17 at 08:19