I was just curious if there would be a way to recover, for example another parameter you could pass to parse. There isn't though.
constprotein={steak:"๐ฅฉ",bacon:"๐ฅ",fake:{shrimp:"๐ค"},array:["๐ฅฉ","๐ฅ","๐ค"]}// looks weird but worksJSON.parse(JSON.stringify(protein,null,"\n\t\n\0\r "))// SyntaxErrorJSON.parse(JSON.stringify(protein,null,"๐ฅ"))// and my favorite:// parses as `{sh: "๐ค", steak: "๐ฅฉ", bacon: "๐ฅ"}`// but breaks nested objects or arrays.JSON.parse(JSON.stringify({steak:"๐ฅฉ",bacon:"๐ฅ"},null,'"sh":"๐ค",'))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Doesn't seem like the output of
JSON.stringify(protein, null, "I ๐")
is recoverable withJSON.parse
.oh ya ๐ฎ ...looking into the docs. it seems like:
Throws a SyntaxError exception if the string to parse is not valid JSON.
Definitely something to keep in mind before using the "space" parameter. thanks for catching that!
I was just curious if there would be a way to recover, for example another parameter you could pass to
parse
. There isn't though.