Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i got below error :

VM230:1 Uncaught SyntaxError: Unexpected token i in JSON at position 1
    at JSON.parse (<anonymous>)
    at eval (eval at <anonymous> (interactionEvents.html:4), <anonymous>:1:6)
    at interactionEvents.html:29
(anonymous) @ VM229:1
(anonymous) @ interactionEvents.html:29


What I have tried:

var a = "{id: 1, label: 'Node 1', title: 'I have a popup!'}";
JSON.parse(a)
Posted
Updated 19-Nov-21 11:30am

{id: 1, label: 'Node 1', title: 'I have a popup!'}
Is an invalid JSON string. It should be
{"id": 1, "label": "Node 1", "title": "I have a popup!"}

Test it, for instance, here: JSONLint - The JSON Validator[^].
You can also use an online validator to check any JSON expression.
e.g. JSON Formatter & Validator[^]
 
Share this answer
 
v3
Comments
TheRealSteveJudge 27-May-19 8:37am    
5*Sorry I edited your question...
That was not my intent.
CPallini 27-May-19 8:39am    
Not a problem at all. Thank you.
You should use double quotes.
{  
   "id":1,
   "label":"Node 1",
   "title":"I have a popup!"
}
 
Share this answer
 
Comments
CPallini 27-May-19 8:39am    
Indeed, ahve my 5.
TheRealSteveJudge 27-May-19 8:41am    
Thank you!
Brilliant! I appreciate the solution #1. Fixed the mess up in local storage not all is working properly
 
Share this answer
 
Comments
CHill60 22-Nov-21 4:23am    
If you want to comment on a solution then use the "Have a Question or Comment?" link next to the solution. Don't post comments (or questions) as a solution to another member's question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900