I'm facing a challenge in my application where I need to extract JSON data. The issue arises when the JSON data retrieved from the service contains dashes ("-"). This leads to an error message saying "Uncaught ReferenceError: person is not defined". For example:
Here is the JSON object:
var JSONObject ={
"name-person":"John Johnson",
"street":"Oslo West 16",
"age":33,
"phone":"555 1234567"};
When I try to access the data using the console log statement below, I encounter the error "Uncaught ReferenceError: person is not defined":
console.log(JSONObject.name-person);
I am unable to modify the source data coming from the service or database. Can someone suggest a solution to handle this kind of data with dashes in it?