Skip to content
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

[gwt] Char sequence "\n" in String messages gets corrupted through PLAIN String serialization in GWT #494

Closed
fabiangebert opened this issue Jul 9, 2012 · 3 comments

Comments

@fabiangebert
Copy link

I am sending JSON over GWT PLAIN serialization (if there is any way of getting the GWT client send plain String without RPC, let me know) and some of the JSON contains multiline. Therefore the server sends:
{body:"this is\na\nmultiline\nmessage"}
But on the client it will arrive as
{body:"this is
a
multiline
message"}
Such that I have to replace [newline] with \n again to make it work
Why is that?

@pierreh
Copy link

pierreh commented Jul 10, 2012

This is to be expected with a JSON string as you are sending, because
the \n is interpreted in javascript as a newline.

On 9-7-2012 17:02, fabiangebert wrote:

I am sending JSON over GWT PLAIN serialization (if there is any way of getting the GWT client send plain String without RPC, let me know) and some of the JSON contains multiline. Therefore the server sends:
{body:"this is\na\nmultiline\nmessage"}
But on the client it will arrive as
{body:"this is
a
multiline
message"}
Such that I have to replace [newline] with \n again to make it work
Why is that?


Reply to this email directly or view it on GitHub:
#494

@fabiangebert
Copy link
Author

No, then I wouldn't have the "" bevor each newline. I think the mistake in the RPC deserializer or Atmosphere deserialization is that it converts \n to [newline] and doesn't respect the \ - it should convert \n to \n and not to [newline]
Or am I mistaking?

@pierreh
Copy link

pierreh commented Jul 11, 2012

Have a look at the changes I made here : https://github.com/pierreh/atmosphere/commits/master
It allows for automatic JSON serialization. Look especially at the gwt-js-demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants