An OpenMath JSON Encoding

OpenMath is a standard for representing the semantics of mathematical objects. This page proposes a new encoding of OpenMath objects as JSON.

OpenMath-JSON is defined using a set of TypeScript Definitions. These act as the normative and editable version of the encoding. The definition is also available as a JSON Schema, allowing for easy validation.

This page acts as the demonstration for the proposed encoding, and at the same provides an API to convert between JSON and XML encoded OpenMath objects.

Read More On GitHub »

Validate OpenMath-JSON



OpenMath-JSON can be validated using one of two ways, via the JSON Schema or via the TypeScript Definition File.

To use the JSON Schema, first download the openmath.json file. You can then make use of any of the Validators able to parse draft-06 and higher. For example, you can use the www.jsonschemavalidator.net website.

To use the TypeScript Definition file, download and include the openmath.d.ts file in your project. You can then use the definitions inside of your TypeScript Code, for example:
import { OMS } from './openmath';
const symbolSIN: OMS = {
    kind: 'OMS',

    cdbase: 'http://www.openmath.org/cd',
    cd: 'transc1',
    name: 'sin'
};
POST

Request

Parameter Type Description
(Body) json JSON object to be validated
kind string (optional) Schema to validate against. Defaults to omany.

Supported kinds are: (case sensitive).

Response

Parameter Type Description
success boolean Indicates if the validator was run.
message string (optional) Message in case the validator failed to run.
result.valid boolean (optional) Inidicates if the request object was valid JSON.
result.errors ValidationError[] (optional) An array of ValidationErrors of why the validation failed.

The response will always be valid JSON. The API also supports JSONP.

ValidationErrors come directly from the underlying validation library j sonschema. The most importand field is the stack field, which contains a message to include in a stack trace of the error.

Convert To OpenMath-JSON



POST

Request

Parameter Type Description
(Body) xml OpenMath XML-encoded object to be encoded as JSON

Response

Parameter Type Description
success boolean Indicates if conversion was successfull.
message string (optional) Message if conversion failed.
result object (optional) converted JSON-encoded OpenMath object.

The response will always be valid JSON. The API also supports JSONP.

Convert To OpenMath-XML

It is easy to transform OpenMath-JSON into the established OpenMath-JSON encoding



POST

Request

Parameter Type Description
(Body) json OpenMath JSON-encoded object to be encoded as XML

Response

Parameter Type Description
success boolean Indicates if conversion was successfull.
message string (optional) Message if conversion failed.
result string (optional) converted XML-encoded OpenMath object (serialized as a string).

The response will always be valid JSON. The API also supports JSONP.