I’m trying to parse this simple JSON,
but its giving me an error:
let myjson = "{rahul: 'kumar', parul: 'sinha'}"
let result = JSON.parse(myjson)
console.log(result)
but it is giving me this error:
Uncaught SyntaxError: Unexpected token r in JSON at position 1
at JSON.parse
>Solution :
JSON doesn’t understand Single quotes (‘)
so use double quotes instead.
let myjson = '{"rahul": "kumar", "parul": "sinha"}'
let result = JSON.parse(myjson)
console.log(result)
Learn more Here