comparison json.ur @ 3:189245a3c075

Wikipedia JSON example working
author Adam Chlipala <adam@chlipala.net>
date Thu, 02 Dec 2010 12:17:51 -0500
parents 478524b9d23a
children 8f7396495045
comparison
equal deleted inserted replaced
2:478524b9d23a 3:189245a3c075
241 in 241 in
242 if String.length s = 0 || String.sub s 0 <> #"{" then 242 if String.length s = 0 || String.sub s 0 <> #"{" then
243 error <xml>JSON record doesn't begin with brace</xml> 243 error <xml>JSON record doesn't begin with brace</xml>
244 else 244 else
245 let 245 let
246 val (r, s') = fromJ (String.substring s {Start = 1, Len = String.length s - 1}) 246 val (r, s') = fromJ (skipSpaces (String.substring s {Start = 1, Len = String.length s - 1}))
247 (@map0 [option] (fn [t ::_] => None) fl) 247 (@map0 [option] (fn [t ::_] => None) fl)
248 in 248 in
249 (@map2 [option] [fn _ => string] [id] (fn [t] (v : option t) name => 249 (@map2 [option] [fn _ => string] [id] (fn [t] (v : option t) name =>
250 case v of 250 case v of
251 None => error <xml>Missing JSON object field {[name]}</xml> 251 None => error <xml>Missing JSON object field {[name]}</xml>