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