When I recently used JS to write a JSON-style string, when I put the JSON form string into the function json.parse (), always error uncaught syntaxerror:unexpected token '
javascript: Among
The string is:
var StrJso2 = "{' UserID ': ' One ', ' Name ': ' WP ', ' email ': ' [email protected] '}";
It looks right, but it's actually a background error.
The correct format is:
var strjso2= ' {"UserID": "One", "Name": "WP", "email": "[email protected]"} ';
Pure JS string preferably using double quotation marks
Java code
So write String strjson= ' {"UserID": One, "Name": {"FirstName": "tht", "LastName": "Tang"}, "email": "[email protected]"} '; Must be wrong, because the single quote is the char type
Correct format:
String strjson= "{' UserID ': One, ' Name ': {' FirstName ': ' tht ', ' LastName ': ' Tang '}, ' email ': ' [email protected] '}";
Or
String strjson= "{\" userid\ ": \" 11\ ", \" name\ ": {\" firstname\ ": \" tht\ ", \" lastname\ ": \" tang\ "}, \" email\ ": \" [Email Protected]\ "}";
How JSON strings are represented in JavaScript and Java code