Mercurial > meta
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:63697ef80a2c | 1:4d103b4450ee |
---|---|
1 open Json | |
2 | |
3 val json_abcd : json {A : int, B : float, C : string, D : bool} = | |
4 json_record {A = "a", B = "b", C = "c", D = "d"} | |
5 | |
1 fun main () : transaction page = return <xml><body> | 6 fun main () : transaction page = return <xml><body> |
2 {[Json.toJson (1 :: 2 :: 8 :: [])]}<br/> | 7 {[toJson (1 :: 2 :: 8 :: [])]}<br/> |
3 {[Json.fromJson "[1,2, 8]" : list int]} | 8 {[fromJson "[1,2, 8]" : list int]} |
4 <hr/> | 9 <hr/> |
5 {[Json.toJson (1.2 :: 2.4 :: (-8.8) :: [])]}<br/> | 10 {[toJson (1.2 :: 2.4 :: (-8.8) :: [])]}<br/> |
6 {[Json.fromJson "[1.4,-2.7, 8.215506]" : list float]} | 11 {[fromJson "[1.4,-2.7, 8.215506]" : list float]} |
7 <hr/> | 12 <hr/> |
8 {[Json.toJson ("hi" :: "bye" :: "tricky\\\" one!" :: [])]}<br/> | 13 {[toJson ("hi" :: "bye" :: "tricky\\\" one!" :: [])]}<br/> |
9 {[Json.fromJson "[\"abc\", \"\\\\whoa\"]" : list string]} | 14 {[fromJson "[\"abc\", \"\\\\whoa\"]" : list string]} |
10 <hr/> | 15 <hr/> |
11 {[Json.toJson (True :: False :: True :: [])]}<br/> | 16 {[toJson (True :: False :: True :: [])]}<br/> |
12 {[Json.fromJson "[true,false, true]" : list bool]} | 17 {[fromJson "[true,false, true]" : list bool]} |
18 <hr/> | |
19 {[toJson {A = 1, B = 2.3, C = "Hi", D = True}]} | |
13 </body></xml> | 20 </body></xml> |