0
var obj = JSON.parse("total(PC+CH)":"50", "Name":"Doe"}');

document.getElementById("demo").innerHTML = obj.total(PC+CH);

Here is the json which has some special characters like + and (). But unable to access the element value using total(PC+CH) since it has some special characters.

How can we get the value of total(PC+CH)?

NOTE: I dont want to use indexing, i want to use total(PC+CH) and get the value

Mister Jojo
  • 20,093
  • 6
  • 21
  • 40
Shanthi K
  • 5
  • 6
  • use `obj["total(PC+CH)"]` – Nitheesh Nov 24 '21 at 11:12
  • var data = {"total(PC+CH)":"50","Name":"Doe"} var stringifyData = JSON.stringify({"total(PC+CH)":"50","Name":"Doe"}) var parsedData = JSON.parse(stringifyData) console.log(parsedData['total(PC+CH)"]) – Ramusesan Nov 24 '21 at 11:19

0 Answers0