-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
XML.toString - Escape nightmare #285
Comments
Can you provide a code and JSON text fragment that demonstrates the problem, and what you would prefer to see in the XML.toString() output? There are no plans now, nor are any expected in the future, where 3rd party libs will be included in the project. See https://github.com/stleary/JSON-java/wiki/FAQ |
Ok! I understand your position to don't use external libs. Then please make a solution to do not escape the &. A little sample:
Output:
But... sending this XML output to another service will be converted to:
Because the special characters need be escape! But has a lot of special characters in so many languages like portuguese, french, spanish, arabic, chinese, german... and the special characters with accents need be escaped correctly to ensure that do not miss the encoding. If pre escape the JSON:
The output is:
And the correct output should be:
No way to make a workaround because the & is always converted to |
I think XML and json are both supposed to support Unicode properly. Maybe On Sep 18, 2016 16:00, "Eduardo Velasques" notifications@github.com wrote:
|
johnjaylward, is not true! When you sends your bytes throgh web services and reverse proxies, and information passing in 3 or 4 web servers and where in each one converts to string, many things can happen... I just need to control the escape because the default escape is very basic. Just it! A flag to not escape. |
I think the right solution would probably be to place the correct Unicode On Sep 18, 2016 17:53, "Eduardo Velasques" notifications@github.com wrote:
|
Like this?
The final result must be:
Sounds perfect! But I think will be hard to accomplish. |
Yes, that was what I was picturing. On Sep 18, 2016 18:11, "Eduardo Velasques" notifications@github.com wrote:
|
What means closed, will not be done? Just to I know to looking for another solution... |
No objection if you want to create a pull request that solves your problem without causing problems to existing applications. |
Ok! ;) |
I believe I have a PR that will fix this. Just writing up the documentation on it now. |
The XML.escape is very basic and when working with latin accents I can not reach a good result!
Will no escape latin accents and if I escape before then the result will be ã (madness)
I suggest to use: org.apache.commons.lang3.StringEscapeUtils.escapeHtml4
Is the better escape solution, works like a charm with all characters in my experience.
Or adds these methods to avoid the default escape:
Thank you!
The text was updated successfully, but these errors were encountered: