Reputation: 2142
I found a difference between Ext JS's (Version 4.1) Ext.JSON.encode()
and Chrome's (Version 21.0.1180.79) JSON.stringify()
when used in Chrome's console:
JSON.stringify({"title": "ä"})
> "{"title":"ä"}"
Ext.JSON.encode({"title": "ä"})
> "{"title":"\u00e4"}"
Since I want to show the results in the browser, I prefer Chrome's result, but I know that I cannot really rely on Chrome's JSON handling in other browsers. So how can I achieve Chrome's result with Sencha's Ext JS?
Upvotes: 3
Views: 5020
Reputation: 498
You need to know that the value is the same. \u00e4 is the real utf-8 representation of the character ä. Chrome may output the ä decoded for better user expirience, but when decoding, both values are same:
JSON.stringify({"title": "ä"})
> "{"title":"ä"}"
Ext.JSON.encode({"title": "ä"})
> "{"title":"\u00e4"}"
JSON.parse('{"title":"ä"}')
> Object {title: "ä"}
Ext.JSON.decode('{"title":"\u00e4"}')
> Object {title: "ä"}
JSON.parse('{"title":"\u00e4"}')
> Object {title: "ä"}
Ext.JSON.decode('{"title":"ä"}')
> Object {title: "ä"}
Upvotes: 1