[Om] JSON Binding for OpenMath?

Alberto González Palomo alberto at matracas.org
Wed May 2 09:52:04 CEST 2018

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)

   Some concrete examples:

   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:

   - 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.

     Alberto González Palomo
     Toledo, España / Saarbrücken, Deutschland

More information about the Om mailing list