Tag Archives: Unexpected token ‘ in JSON at position 2 at JSON.parse

Unexpected token ‘ in JSON at position 2 at JSON.parse

var c = "[{'mid':'28275','url':'\/static\/image\/realNameImage\/2020\/January\/7\/A30gdmb2_750X1000.png'}, {'mid':'28275','url':'\/static\/image\/realNameImage\/2020\/January\/7\/A30gdmb2_750X1000.png'}]"

console.log(JSON.parse(c))

At first glance, the code is completely flawless, but there is always unexpected red
Uncaught SyntaxError: Unexpected token ' in JSON at position 2 at JSON.parse (< anonymous>) at < anonymous>: 1:18


But I have no problem with this operation

var c = '[{"cid":"28275","url":"\/static\/image\/realNameImage\/2020\/January\/7\/5wMUlxsZ_750X1000.png"},{"cid":"28275","url":"\/static\/image\/realNameImage\/2020\/January\/7\/PE4ju0oT_750X1000.png"}]'

console.log(JSON.parse(c))

Fuck, why

What’s the reason

this article is shared by WeChat official account – itDog programmer (newObject-007).