[Om] JSON Binding for OpenMath?

David Carlisle davidc at nag.co.uk
Wed May 2 14:42:48 CEST 2018


On 02/05/2018 08:52, Alberto González Palomo wrote:
> Michael Kohlhase wrote on 02/05/18 at 08:57:
>> we have come across the need to communicate OpenMath Objects to 
>> JavaScript.
>>
>> We could go traditional and send over XML and have JS parse that into JS
>> Objects, or we could use a JSON binding for OpenMath.
>>
>> It actually seems that Nathan Carter has already done something very
>> much like that.  [1]
>>
>> Would it make sense to standardize a JSON binding of OpenMath? After
>> all, JSON is one of the practical competitors for XML and used A LOT on
>> the web.
>>
>> [1] https://lurchmath.github.io/openmath-js/site/
> 
>    For anyone else interested, here is a direct link to the docs: 
> (please note that I'm not the author)
> https://github.com/lurchmath/openmath-js/blob/master/openmath.litcoffee#openmath-module 
> 
> 
>    Some concrete examples:
> https://github.com/lurchmath/openmath-js/blob/master/openmath-spec.litcoffee#should-decode-valid-simple-forms 
> 
> 
>    For instance, let's compare the encoding of $x+5$:
> 
>    - OpenMath:
>      <OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS 
> cd="arith1" name="plus"/><OMV name="x"/><OMI>5</OMI></OMA></OMOBJ>
> 
>    - openmath-js:
>      {"t":"a", c:[ {"t":"sy", "cd":"arith1", "n":"plus"}, {"t":"v", 
> "n":"x"}, {"t":"i", "v":"5"} ] }
> 
>    There is another way to encode XML as JSON, called JSONML, which is 
> pretty much LISP with square brackets:
> http://jsonml.org/
> 
>    - JSONML:
>      ["OMOBJ", {"xmlns":"http://www.openmath.org/OpenMath"}, ["OMA", 
> ["OMS", {"cd":"arith1", "name":"plus"}], ["OMV", {"name":"x"}], ["OMI", 
> "5"] ]]
> 
>    As a standard encoding, I'd rather recommend JSONML because it is a 
> straight mapping of the XML syntax and there are implementations of it 
> for several programming languages. I've used it extensively for web 
> applications, generating HTML and XML for both personal projects and 
> work for customers, and it works well in practice.
> 
>    Cheers,

I've no particular objection and we should say something about JSON 
somewhere, even if only on the website and not in the standard.

jsonml looks useful for us in that context as it doesn't require a new 
openmath encoding as it's "just" an alternative serialisation of XML.

That said, the benefits of json for passing openmath are largely 
cosmetic in many cases as the cost isn't the xml tagging it's the cost 
of sending numeric data via a text representation of its decimal form, 
and JSON doesn't help with that.

The original openmath binary encoding was of course there for that 
reason but more generally one of schema-aware binary encodings of xml to 
allow numeric data to be sent without serialising as strings of decimal 
digits could be mentioned in that context (exi, or fast infoset or asn.1 
or ...) I'm a bit out of the loop of current standards in that area but 
wikipedia has an overview https://en.wikipedia.org/wiki/Binary_XML


David

Disclaimer

The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.openmath.org/pipermail/om/attachments/20180502/117e124d/attachment.html>


More information about the Om mailing list