I have a string which gets serialized to JSON in Javascript, and then deserialized to Java.
It looks like if the string contains a degree symbol, then I get a problem.
I could use some help in figuring out who to blame:
- is it the Spidermonkey 1.8 implementation? (this has a JSON implementation built-in)
- 是Google gson吗?
- is it me for not doing something properly?
Here's what happens in JSDB:
js>s='15\u00f8C'
15°C
js>JSON.stringify(s)
"15°C"
I would have expected "15\u00f8C'
which leads me to believe that Spidermonkey's JSON implementation isn't doing the right thing... except that the JSON homepage's syntax description (is that the spec?) says that a char can be
任何Unicode字符-
因此,它可能会按原样传递字符串,而不会将其编码为\u00f8.在这种情况下,我认为问题出在gson库上.
Can anyone help?
I suppose my workaround is to use either a different JSON library, or manually escape strings myself after calling JSON.stringify()
-- but if this is a bug then I'd like to file a bug report.