JSON Interface
The JSON interface offers several functions to serialize TM-constructs and TMCL-standard-constraints as JSON-strings. The RESTful interface is also able to serve these JSON-objects by calling certain URLs.
The goal of the JSON interface is offering data for generating the Isidorus-UI.
The defined objects served by the JSON interface are also expressed in EBNF and a less formal syntax xtm_json.
JSON Exporter
The package "json-exporter" offers the functions:
- export-construct-as-isidorus-json
- a generic function which is bound to most classes defined in the isidorus data model, e.g. TopicC, NameC, AssociationC, FragmentC, ...
- serializes the called object to a JSON string by using the cl-json framework and several helpr functions
- get-all-topic-psis
- returns a JSON string that represents a list of lists, every single list contains all PSIs of a topic. The entire list contains lists of these serialized topics. This functions can be used to represent all Topics in the store
- to-json-string-summary
- this function serializes the called topic object to a JSON-string which contains all necessary data as a kind of summary. I. e. all identifiers, instanceOfs, name-values (the actual name-strings) and occurrence-values (the actual occurrence-strings) are serialized
- make-topic-summary
- returns a JSONB-string representing a list of serialized topic-summaries
Further (private) JSON-functions are defined in the package "rest-interface" and the json-tmcl section. These are functions which are needed to generate additional information for the Isidorus-UI, e.g. the tree-view.
JSON Importer
The "json-importer" offers the function "import-from-isidorus-json" which imports a JSON-string and stores it in the data base. "json-to-elem" takes the following parameters:
- json-string: which represents the serialized TM-fragment in JSON representation as defined in EBNF and xtm_json
- xtm-id: an optional parameter that is initialized with the public package variable "*json-xtm*" which is set to the value "json-xtm". This is value is used similar as a "file identifier".
JSON TMCL
The JSON TMCL section offers JSON-data which contains all stored standard-constraints. The implemented module is based on the TMCL-draft dated to 2008-08-07 and is able to serialize all defined standard-constraints. The isidorus-json-tmcl-module differs in the way of handling definitions of regular expressions of names and occurrences.
The TMCL draft allows to define a regular expression for a specific name/occurrence type. This regular expression has to match every name/occurrence of this type. The difference in Isidorus is that you can define more than one regular expression for a name/occurrence. The defined cardinalities determine if the object is valid or not, i.e. you can define the cardinality of exactly 1 and the regular expression "abc.*" for the occurrence-type "otype" and additionally the cardinality "*" of the regular expression ".*" to the same occurrence-type.
The TMCL-section contains only private functions which are used by the "rest-interface". The most important function that offers the actual TMCL-JSON-string is named "get-constraints-of-fragment". It takes the paramters:
- topic-psis: a list that contains all PSIs of all requested topics
- treat-as: a symbol either set to "'type" or "'instance". If treat-as is set to "'type" the passed topic-PSIs are treated as topic types otherwise the passed PSI-list must have the length of exactly one item. This item is treated as an instance.