Mercurial > meta
diff tests/testJson.ur @ 2:478524b9d23a
Parsed a JSON record
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 02 Dec 2010 11:59:55 -0500 |
parents | 4d103b4450ee |
children | 189245a3c075 |
line wrap: on
line diff
--- a/tests/testJson.ur Thu Dec 02 11:35:01 2010 -0500 +++ b/tests/testJson.ur Thu Dec 02 11:59:55 2010 -0500 @@ -3,18 +3,21 @@ val json_abcd : json {A : int, B : float, C : string, D : bool} = json_record {A = "a", B = "b", C = "c", D = "d"} -fun main () : transaction page = return <xml><body> - {[toJson (1 :: 2 :: 8 :: [])]}<br/> - {[fromJson "[1,2, 8]" : list int]} - <hr/> - {[toJson (1.2 :: 2.4 :: (-8.8) :: [])]}<br/> - {[fromJson "[1.4,-2.7, 8.215506]" : list float]} - <hr/> - {[toJson ("hi" :: "bye" :: "tricky\\\" one!" :: [])]}<br/> - {[fromJson "[\"abc\", \"\\\\whoa\"]" : list string]} - <hr/> - {[toJson (True :: False :: True :: [])]}<br/> - {[fromJson "[true,false, true]" : list bool]} - <hr/> - {[toJson {A = 1, B = 2.3, C = "Hi", D = True}]} -</body></xml> +fun main () : transaction page = + d <- return (fromJson "{\"a\": 1, \"b\": 2.3, \"c\": \"Hi\", \"d\": true}" : {A : int, B : float, C : string, D : bool}); + return <xml><body> + {[toJson (1 :: 2 :: 8 :: [])]}<br/> + {[fromJson "[1,2, 8]" : list int]} + <hr/> + {[toJson (1.2 :: 2.4 :: (-8.8) :: [])]}<br/> + {[fromJson "[1.4,-2.7, 8.215506]" : list float]} + <hr/> + {[toJson ("hi" :: "bye" :: "tricky\\\" one!" :: [])]}<br/> + {[fromJson "[\"abc\", \"\\\\whoa\"]" : list string]} + <hr/> + {[toJson (True :: False :: True :: [])]}<br/> + {[fromJson "[true,false, true]" : list bool]} + <hr/> + {[toJson {A = 1, B = 2.3, C = "Hi", D = True}]}<br/> + A: {[d.A]}, B: {[d.B]}, C: {[d.C]}, D: {[d.D]} + </body></xml>