Closed ShirasawaSama closed 3 years ago
Why are you comparing what's returned by parse and stringify ? Those are 2 different things
@rom1504 I stringify an item NBT with a double quoted name { DisplayName: '"' }
and tried to parse it. I found that it could not be parsed.
console.log(JSON.parse(parse(stringify({ DisplayName: JSON.stringify('"') })).DisplayName))
What do you actually want to do ? Is there any error ?
@rom1504 I need parse an item from NBT, modify its display name, and stringify it.
However, when I parse the serialized data again, the DisplayName
string obtained is inconsistent with the expected one.
I expected "\""
, but I got """
.
Can you try not using json parse and json stringify ? And posting the code that does what you want to do
The \ should only appear in stringified form, not parsed
const str1 = '"\\""'
const str2 = parse(stringify({ str1 })).str1
console.log(str1 === str2) // false
Sorry, it's my problem
And this works: