I have the below JSON
[
{ "first-Name": "John", "lastName": "Scott" },
{ "first-Name": "Anna", "lastName": "Smith" },
{ "first-Name": "Lima", "lastName": "Jones" }
]
Specifically it contains a property first-Name
. Now, whenever I try to get data for that particular property it throws an error.
The error is:
Uncaught ReferenceError: Name is not defined(anonymous function)
@ VM169:1InjectedScript._evaluateOn
@ VM128:883InjectedScript._evaluateAndWrap
@ VM128:816InjectedScript.evaluateOnCallFrame
@ VM128:942$.ajax.success
@ App.js:11n.Callbacks.j
@ jquery-2.1.3.min.js:2n.Callbacks.k.fireWith
@ jquery-2.1.3.min.js:2x
@ jquery-2.1.3.min.js:4n.ajaxTransport.k.cors.a.crossDomain.send.b
@ jquery-2.1.3.min.js:4
The way I try to get data is: data[0].first-Name
in Chrome's console. However, if I try to get data for the property lastName
as data[0].lastName
is giving the output. So what is the issue and how can I fix this?