view 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 source
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>
  {[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>