dispatch.json.JsValue Chokes on Newlines

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

dispatch.json.JsValue Chokes on Newlines

lambdaknight
So, I ran into an issue with dispatch.json.

JsValue.fromString(JsString("Hello\nGoodbye").toString)

That will choke in die, throwing a "Illegal JSON format" exception.  It's easy to fix.  Line 126 of Json.scala should change to:

case JsString(s) => "\"" + s.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\\"", "\\\\\"").replace("\n", "\\n") + "\""
Reply | Threaded
Open this post in threaded view
|

Re: dispatch.json.JsValue Chokes on Newlines

n8han
Administrator
Thanks, finally committed this.
https://github.com/n8han/Databinder-Dispatch/commit/e8f49eee808aad4fddca692821cd89229d7a5ffc

Nathan

On 12/16/2010 06:28 PM, lambdaknight [via Databinder] wrote:
So, I ran into an issue with dispatch.json.

JsValue.fromString(JsString("Hello\nGoodbye").toString)


That will choke in die, throwing a "Illegal JSON format" exception.  It's easy to fix.  Line 126 of Json.scala should change to:

case JsString(s) => "\"" + s.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\\"", "\\\\\"").replace("\n", "\\n") + "\""



View message @ http://databinder.3617998.n2.nabble.com/dispatch-json-JsValue-Chokes-on-Newlines-tp5843953p5843953.html
To start a new topic under Databinder, email [hidden email]
To unsubscribe from Databinder, click here.