caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Berke Durak" <berke.durak@gmail.com>
To: "Robert Fischer" <robert@fischerventure.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] picking / marshaling to strings in ocaml-revision-stable way
Date: Sat, 31 May 2008 23:34:34 +0200	[thread overview]
Message-ID: <b903a8570805311434t54e632ccua308f838ebbc5803@mail.gmail.com> (raw)
In-Reply-To: <48418421.5090601@fischerventure.com>

On Sat, May 31, 2008 at 7:00 PM, Robert Fischer
<robert@fischerventure.com> wrote:
> How far is the reach from the Jane St S-exp library from producing JSON?  I've not actually looked at it, but that'd be super nifty in the interoperation world.

If you just want JSON syntax, you can use Sexplib to convert an
arbitrary type to a
Sexp.t

  type t = Atom of string | List of t list

and then output in Json format:

let rec output_json oc = function
| Atom u -> fprintf oc "%S" u
| List xl -> fprintf oc "[%a]" (fun oc xl -> List.iter (fun x ->
fprintf "%a," output_json x) xl) xl

You can then do the same thing for parsing.
-- 
Berke


  parent reply	other threads:[~2008-05-31 21:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-31  6:43 Luca de Alfaro
2008-05-31  7:24 ` [Caml-list] " asmadeus77
2008-05-31  8:43 ` Jacques Garrigue
2008-05-31  9:38   ` Berke Durak
2008-05-31 16:54     ` Luca de Alfaro
2008-05-31 17:00       ` Robert Fischer
2008-05-31 17:24         ` Luca de Alfaro
2008-05-31 22:18           ` Martin Jambon
2008-05-31 17:25         ` blue storm
2008-05-31 21:34         ` Berke Durak [this message]
2008-05-31 22:51           ` Stefano Zacchiroli
2008-06-02  9:04             ` Berke Durak
2008-06-02  9:21               ` Stefano Zacchiroli
2008-06-01 11:14           ` Martin Jambon
2008-06-02 11:13         ` Richard Jones
2008-05-31 17:06       ` Yaron Minsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b903a8570805311434t54e632ccua308f838ebbc5803@mail.gmail.com \
    --to=berke.durak@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=robert@fischerventure.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).