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