Re: [Caml-list] picking / marshaling to strings in ocaml-revision-stable way

On Sun, Jun 1, 2008 at 12:51 AM, Stefano Zacchiroli <zack@upsilon.cc> wrote:
> On Sat, May 31, 2008 at 11:34:34PM +0200, Berke Durak wrote:
>> and then output in Json format:
>
> Aren't you being naive about escaping needs here?
>
> I don't know the details of the two involved languages, but it would
> mean to be very lucky if the escaping conventions are the same ...
Of course, the code was intended for illustrative purposes. JSON
escapes characters based using 4-digit Unicode hex codes.
Except for \n, \r, etc. sot it would probably work for ASCII.
Martin Jambon:
> You won't obtain anything useful if you treat Atoms as JSON strings and Lists as JSON arrays because JSON has also null, numbers, booleans and objects.
The real issue is that records are mapped to lists of lists, making
lookup difficult and cumbersome. But that's still JSON syntax,
formally... You could theoretically write a piece of code to
"recognize" a record and emit a Json object but that wouldn't be very
elegant.
> This is the JSON standard: http://www.json.org/
I know, we are using Json (but not Json-wheel) to pass the annotated
syntax tree from the C legacy front-end to the Ocaml JVM backend.
However we are using Sexplib for all the internal serialization needs
(mostly for debugging) since it integrates so well with Ocaml.
> And that is the concrete type used to represent JSON trees in the json-wheel library (which json-static uses):
That's a blessing but also a curse. You retain more information on
your format, but that also complexifies anything that manipulates
syntax trees.
The nice thing about Sexp is that its Path module provides a small
manipulation language for migrating your data. If that's not enough,
you can always load it in any Scheme or Lisp and spit it back.
--
Berke Durak