English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
Long-term storage of values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-03-21 (14:28)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Long-term storage of values
On Fri, 21 Mar 2008, Dario Teixeira wrote:

>> No JSON needs to be written by hand.
>> Here's a simple example:
>> type json point = { x : int; y : int }  (* an OCaml record *)
>> It creates the functions with the following signature:
>> val json_of_point : point -> Json_type.t
>> val point_of_json : Json_type.t -> point
> Hi,
> And thanks for the clarification, Martin.  Okay then, this makes
> json-static as convenient as Sexplib, and the strongest candidate
> if human-readability is a requirement.  It should also come in
> very handy for browser/server communication (AJAX) using the
> Ocsigen platform, for example.

I have to say that json-static does not support parametrized types other 
than a few pervasive ones (lists, arrays, hash tables, options, ...).

Like the other syntax extensions that deal with types it uses the type 
names to determine the JSON type to use, 
i.e. if 2 names are used to refer to the same OCaml type, 
they can use 2 different JSON representations.
A common, predefined example is the "assoc" type, which is defined as 

type 'a assoc = (string * 'a) assoc

and would use a JSON object rather than a JSON array of arrays, which is
common usage.