lib/simple_json_reader: unprotect special char in strings
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 3 Feb 2014 03:59:30 +0000 (22:59 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sat, 22 Feb 2014 13:17:32 +0000 (08:17 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/simple_json_reader/simple_json_reader.nit
tests/sav/test_deserialization.res

index f03bf91..3fd3d22 100644 (file)
@@ -50,7 +50,10 @@ end
 
 redef class Nstring
        # FIXME support \n, etc.
-       fun to_nit_string: String do return text.substring(1, text.length-2)
+       fun to_nit_string: String do return text.substring(1, text.length-2).
+               replace("\\\\", "\\").replace("\\\"", "\"").replace("\\b", "\b").
+               replace("\\/", "/").replace("\\n", "\n").replace("\\r", "\r").
+               replace("\\t", "\t")
 end
 
 redef class Nvalue_object
index 529c71f..bb3c10f 100644 (file)
@@ -33,5 +33,6 @@
 {"__kind": "obj", "__id": 0, "__class": "D", "b": false, "f": 123.123, "i": 2345, "s": "new line ->\n<-", "n": null, "ii": 1111, "ss": "\tf\"\r\\\/", "d": {"__kind": "ref", "__id": 0}}
 
 # Back in Nit:
-<D: <B: <A: false 123.123 2345 new line ->\n<- false> 1111 \tf\"\r\\\/> true>
+<D: <B: <A: false 123.123 2345 new line ->
+<- false> 1111         f"\r\/> true>