Created
May 21, 2009 16:30
-
-
Save jpbougie/115558 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/scala/dispatch/Json.scala b/src/main/scala/dispatch/Json.scala | |
index 776da7b..14ef7e9 100644 | |
--- a/src/main/scala/dispatch/Json.scala | |
+++ b/src/main/scala/dispatch/Json.scala | |
@@ -123,7 +123,7 @@ object JsValue { | |
def toJson(x: JsValue): String = x match { | |
case JsNull => "null" | |
case JsBoolean(b) => b.toString | |
- case JsString(s) => "\"" + s + "\"" | |
+ case JsString(s) => "\"" + s.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\\"", "\\\\\"") + "\"" | |
case JsNumber(n) => n.toString | |
case JsArray(xs) => xs.map(toJson).mkString("[",", ","]") | |
case JsObject(m) => m.map{case (key, value) => toJson(key) + " : " + toJson(value)}.mkString("{",", ","}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment