JSON.parse reported an error

var a = [{"id": "102"," name ":" guarantee "}, {" id ":" 104", "name": "out of the box"}]
an is the data returned by the backend to typeof the data found to be of string type JSON.parse (a)
error Uncaught SyntaxError: Unexpected token o in JSON at position 1

at JSON.parse (<anonymous>)
 
Jul.28,2021

your an is obviously an object, so what else? JSON.parse is used to convert strings into objects


you can see the difference between JSON.parse and JSON.stringify
clipboard.png


can you print the a you returned in the background? It is estimated that there is something wrong with the format returned by the background.


see the difference for yourself

  

json.parse is a way to transfer strings to objects. Are you sure you conform to this format? ,

Menu