-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ToJson()无法对特殊字符进行正确的转译 #107
Comments
Which version of LitJson har you using? Did a quick .NET Fiddle ( https://dotnetfiddle.net/3cGvQN ) and it outputs Sending that json to json lint says it's valid json ( https://jsonlint.com/?json={%22name%22:%22\u0003%22} ) Created an jsfiddle ( https://jsfiddle.net/nmecws5x/ ) and it parses the outputed json fine So unsure what's expected and unexpected. |
The results are as follows: {"name":"\u0003","key":"\u4E2D\u6587"} Sorry, I used an old version. I upgraded it to the latest version, but because of the particularity of Chinese, it converted all Chinese into unicode, which caused a serious decline in readability. In fact, Chinese does not need to be re-coded. 结果为:{"name":"\u0003","key":"\u4E2D\u6587"} |
@mnonmcn ok, but there's no breaking bug then? But a feature request to not encode certain characters? |
I support the code in Chinese after line 269 of the JsonWriter.cs file. enhance readability,This solves another problem at the same time.https://github.com/LitJSON/litjson/issues/78我对代码进行了对中文的支持,放在JsonWriter.cs文件的第 269 行后,增强可读性,这同时解决了另外一个问题https://github.com/LitJSON/litjson/issues/78 |
I see, would it be possible for you to send a pull request with this change? |
Is this still open? I found this from https://up-for-grabs.net/#/filters?labels=88&tags=c%23 and was about to consider this as an option to contribute to (assuming it's a good first issue on this). |
Currently the escaping strategy of LitJson that escapes all non-ascii characters is actually fine. The problem is that people may want those graphic characters to be kept, not only chinese characters, so imho excluding the range [0x4e00, 0x9fa5] (more precisely, CJK Unified Ideographs) is not the solution. |
ToJson () can't translate special characters correctly, which inverts the string of ToJson () data in browsers such as Chorme.
JSON. parse (json) cannot be parsed correctly
Expected results:{"name":"\u0003"}
Actual results:{"name": "�"}
Sorry, it's automatically translated with a translator.
ToJson()无法对特殊字符进行正确的转译,这倒置ToJson() 数据的字符串在Chorme等浏览器中 JSON.parse(json)不能正确解析
正确的结果:{"name":"\u0003"}
实测的结果:{"name": "�"}
The text was updated successfully, but these errors were encountered: