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? ,

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35119-3432f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35119-3432f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?