1. Environment
- mac us
- vscode
- view2.x
2. Reasons and corresponding solutions
Error converting string object to object object with JSON.parse(value):
SyntaxError: Unexpected token o in JSON at position 1
- Repeated conversion: caused by the value itself being an object object, because the value itself is an object object, and then using the JSON.parse(value) method returns an [object, Object] object, which cannot be recognized by JSON.parse(value) o resulting in an error;
reference: SyntaxError: Unexpected token o in JSON at position 1
Solution: Remove the conversion of JSON.parse(value)
- The format of the attribute in the converted string is incorrect:
It should be noted that the attributes in the converted string should use quotation marks, and the overall method is single quotation marks and double quotation marks; the
explanation comes from: https://blog.csdn.net/weixin_41646716/article/details/80939466
Solution: Use the eval(value) function instead of JSON.parse(value) for conversion