Mercurial > meta
comparison json.ur @ 18:6cd839818393
Adjust to name change for [Top.id]
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 29 Dec 2011 14:15:02 -0500 |
parents | 8f7396495045 |
children | 8de201d70b91 |
comparison
equal
deleted
inserted
replaced
17:1a915f89f23a | 18:6cd839818393 |
---|---|
203 {ToJson = toJ, | 203 {ToJson = toJ, |
204 FromJson = fromJ} | 204 FromJson = fromJ} |
205 end | 205 end |
206 | 206 |
207 fun json_record [ts ::: {Type}] (fl : folder ts) (jss : $(map json ts)) (names : $(map (fn _ => string) ts)) : json $ts = | 207 fun json_record [ts ::: {Type}] (fl : folder ts) (jss : $(map json ts)) (names : $(map (fn _ => string) ts)) : json $ts = |
208 {ToJson = fn r => "{" ^ @foldR3 [json] [fn _ => string] [id] [fn _ => string] | 208 {ToJson = fn r => "{" ^ @foldR3 [json] [fn _ => string] [ident] [fn _ => string] |
209 (fn [nm ::_] [t ::_] [r ::_] [[nm] ~ r] (j : json t) name v acc => | 209 (fn [nm ::_] [t ::_] [r ::_] [[nm] ~ r] (j : json t) name v acc => |
210 escape name ^ ":" ^ j.ToJson v ^ (case acc of | 210 escape name ^ ":" ^ j.ToJson v ^ (case acc of |
211 "" => "" | 211 "" => "" |
212 | _ => "," ^ acc)) | 212 | _ => "," ^ acc)) |
213 "" fl jss names r ^ "}", | 213 "" fl jss names r ^ "}", |
257 else | 257 else |
258 let | 258 let |
259 val (r, s') = fromJ (skipSpaces (String.substring s {Start = 1, Len = String.length s - 1})) | 259 val (r, s') = fromJ (skipSpaces (String.substring s {Start = 1, Len = String.length s - 1})) |
260 (@map0 [option] (fn [t ::_] => None) fl) | 260 (@map0 [option] (fn [t ::_] => None) fl) |
261 in | 261 in |
262 (@map2 [option] [fn _ => string] [id] (fn [t] (v : option t) name => | 262 (@map2 [option] [fn _ => string] [ident] (fn [t] (v : option t) name => |
263 case v of | 263 case v of |
264 None => error <xml>Missing JSON object field {[name]}</xml> | 264 None => error <xml>Missing JSON object field {[name]}</xml> |
265 | Some v => v) fl r names, s') | 265 | Some v => v) fl r names, s') |
266 end | 266 end |
267 end} | 267 end} |