|
@@ -1,5 +1,5 @@
|
|
--- json-stream-printer.sml.orig 2017-07-14 22:32:40.000000000 +0200
|
|
--- json-stream-printer.sml.orig 2017-07-14 22:32:40.000000000 +0200
|
|
-+++ json-stream-printer.sml 2017-10-25 01:43:40.211305000 +0200
|
|
|
|
|
|
++++ json-stream-printer.sml 2017-10-25 20:33:53.541874000 +0200
|
|
@@ -66,7 +66,7 @@
|
|
@@ -66,7 +66,7 @@
|
|
then TextIO.output(strm, String.extract(tenSpaces, 10-n, NONE))
|
|
then TextIO.output(strm, String.extract(tenSpaces, 10-n, NONE))
|
|
else (TextIO.output(strm, tenSpaces); prIndent(n-10))
|
|
else (TextIO.output(strm, tenSpaces); prIndent(n-10))
|
|
@@ -9,6 +9,29 @@
|
|
end
|
|
end
|
|
|
|
|
|
fun incIndent (P{indent, ...}, n) = indent := !indent + n;
|
|
fun incIndent (P{indent, ...}, n) = indent := !indent + n;
|
|
|
|
+@@ -103,14 +103,14 @@
|
|
|
|
+ fun tr (i, chrs) = (case getWChar i
|
|
|
|
+ of SOME(wchr, i) => if (wchr <= 0w126)
|
|
|
|
+ then (case UTF8.toAscii wchr
|
|
|
|
+- of #"\"" => "\\\""
|
|
|
|
+- | #"\\" => "\\\\"
|
|
|
|
+- | #"/" => "\\/"
|
|
|
|
+- | #"\b" => "\\b"
|
|
|
|
+- | #"\f" => "\\f"
|
|
|
|
+- | #"\n" => "\\n"
|
|
|
|
+- | #"\r" => "\\r"
|
|
|
|
+- | #"\t" => "\\t"
|
|
|
|
++ of #"\"" => tr(i, "\\\"" :: chrs)
|
|
|
|
++ | #"\\" => tr(i, "\\\\" :: chrs)
|
|
|
|
++ | #"/" => tr(i, "\\/" :: chrs)
|
|
|
|
++ | #"\b" => tr(i, "\\b" :: chrs)
|
|
|
|
++ | #"\f" => tr(i, "\\f" :: chrs)
|
|
|
|
++ | #"\n" => tr(i, "\\n" :: chrs)
|
|
|
|
++ | #"\r" => tr(i, "\\r" :: chrs)
|
|
|
|
++ | #"\t" => tr(i, "\\t" :: chrs)
|
|
|
|
+ | c => if (wchr < 0w32)
|
|
|
|
+ then tr(i, F.format "\\u%04x" [F.WORD wchr] :: chrs)
|
|
|
|
+ else tr(i, str c :: chrs)
|
|
@@ -124,7 +124,7 @@
|
|
@@ -124,7 +124,7 @@
|
|
|
|
|
|
fun beginObject (p as P{ctx, ...}) = (
|
|
fun beginObject (p as P{ctx, ...}) = (
|
|
@@ -23,7 +46,7 @@
|
|
fun prEnd ctx' = (
|
|
fun prEnd ctx' = (
|
|
ctx := ctx';
|
|
ctx := ctx';
|
|
- indent(p, ~1); pr(p, "}"); decIndent (p, 2))
|
|
- indent(p, ~1); pr(p, "}"); decIndent (p, 2))
|
|
-+ indent(p, 0); pr(p, "}"); decIndent (p, 1))
|
|
|
|
|
|
++ decIndent (p, 1); indent(p, 0); pr(p, "}"))
|
|
in
|
|
in
|
|
case !ctx
|
|
case !ctx
|
|
of OBJECT ctx' => (nl p; prEnd ctx')
|
|
of OBJECT ctx' => (nl p; prEnd ctx')
|
|
@@ -39,7 +62,7 @@
|
|
fun prEnd ctx' = (
|
|
fun prEnd ctx' = (
|
|
ctx := ctx';
|
|
ctx := ctx';
|
|
- indent(p, ~1); pr(p, "]"); decIndent (p, 2))
|
|
- indent(p, ~1); pr(p, "]"); decIndent (p, 2))
|
|
-+ indent(p, 0); pr(p, "]"); decIndent (p, 1))
|
|
|
|
|
|
++ decIndent (p, 1); indent(p, 0); pr(p, "]"))
|
|
in
|
|
in
|
|
case !ctx
|
|
case !ctx
|
|
of ARRAY ctx' => (nl p; prEnd ctx')
|
|
of ARRAY ctx' => (nl p; prEnd ctx')
|