summaryrefslogtreecommitdiff
path: root/src/json.sml
diff options
context:
space:
mode:
authorGravatar Simon Van Casteren <simonvancasteren@localhost.localdomain>2019-12-10 22:44:51 +0100
committerGravatar Simon Van Casteren <simonvancasteren@localhost.localdomain>2019-12-13 11:46:57 +0100
commite4f98c318fcadff9247c83d1659a39b15e8c9d58 (patch)
tree3f1c97ca4d254e2cff4f62575a58d919511ed34f /src/json.sml
parent3515286a783fb1eb38acc001d23389dd67fdc910 (diff)
First working version of publishDiagnostics
Diffstat (limited to 'src/json.sml')
-rw-r--r--src/json.sml12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/json.sml b/src/json.sml
index f189cc4d..cc9ea6ae 100644
--- a/src/json.sml
+++ b/src/json.sml
@@ -114,8 +114,12 @@ struct
and parseChars () =
let
fun pickChars s =
- if peek () = #"\"" (* " *) then s else
- pickChars (s ^ String.str (take ()))
+ if peek () = #"\"" (* " *)
+ then s
+ else
+ if peek () = #"\\" andalso (String.sub (!inputData, 1)) = #"\""
+ then (consume "\\\""; pickChars (s ^ "\""))
+ else pickChars (s ^ String.str (take ()))
in
pickChars ""
end
@@ -256,8 +260,8 @@ fun parse (str: string): json =
fun print (ast: json): string =
case ast of
Array l => "["
- ^ List.foldl (fn (a, acc) => acc ^ "," ^ print a) "" l
- ^ "]"
+ ^ List.foldl (fn (a, acc) => acc ^ (if acc = "" then "" else ", ") ^ print a) "" l
+ ^ "]"
| Null => "null"
| Float r => Real.toString r
| String s =>