Mercurial > meta
diff tests/testJson.ur @ 1:4d103b4450ee
Converted a record to JSON
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 02 Dec 2010 11:35:01 -0500 |
parents | 63697ef80a2c |
children | 478524b9d23a |
line wrap: on
line diff
--- a/tests/testJson.ur Thu Dec 02 11:10:57 2010 -0500 +++ b/tests/testJson.ur Thu Dec 02 11:35:01 2010 -0500 @@ -1,13 +1,20 @@ +open Json + +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> - {[Json.toJson (1 :: 2 :: 8 :: [])]}<br/> - {[Json.fromJson "[1,2, 8]" : list int]} + {[toJson (1 :: 2 :: 8 :: [])]}<br/> + {[fromJson "[1,2, 8]" : list int]} <hr/> - {[Json.toJson (1.2 :: 2.4 :: (-8.8) :: [])]}<br/> - {[Json.fromJson "[1.4,-2.7, 8.215506]" : list float]} + {[toJson (1.2 :: 2.4 :: (-8.8) :: [])]}<br/> + {[fromJson "[1.4,-2.7, 8.215506]" : list float]} <hr/> - {[Json.toJson ("hi" :: "bye" :: "tricky\\\" one!" :: [])]}<br/> - {[Json.fromJson "[\"abc\", \"\\\\whoa\"]" : list string]} + {[toJson ("hi" :: "bye" :: "tricky\\\" one!" :: [])]}<br/> + {[fromJson "[\"abc\", \"\\\\whoa\"]" : list string]} <hr/> - {[Json.toJson (True :: False :: True :: [])]}<br/> - {[Json.fromJson "[true,false, true]" : list bool]} + {[toJson (True :: False :: True :: [])]}<br/> + {[fromJson "[true,false, true]" : list bool]} + <hr/> + {[toJson {A = 1, B = 2.3, C = "Hi", D = True}]} </body></xml>