JSON metadata in SData
JSON Metadata in SData appears in the following structures:
- Type definitions: defines the SData-recognized set of types.
- Links (hypermedia controls): are JSON objects describing operations
(Create/Read/Update/Delete and also SData queries and services) on resources. - Embedded metadata: covers metadata provided within a resource representation. It is optionally attached to resources and their properties.
- Prototype: prototypes are the JSON counterpart of schemas. In contrast to the detailed and
restrictive nature of an XSD document, the prototype is:
- Expressed in JSON.
- Simple and compact, making use of string composition to bind a generic template to the information delivered at the resource level.
The JSON characteristics are:
- Metadata is expressed in JSON and relates to resource kind representations and their properties; there is no overarching prototype that describes an entire contract (in contrast to the schema in SData v1.1).
- The static/structural metadata of a representation SHOULD be collected in a JSON object called
$prototype.
- Prototypes describe, by means of metadata, the characteristics of a representation (e.g., structure, type, links).
- A complete resource (i.e. containing both the data and the metadata) is obtained by a merge and substitution process combining the raw data and the metadata contained in the prototype.
- Representations and prototypes are ideally in a 1-1 relationship.
- Metadata MAY be embedded in responses, but is easy to separate from the raw payload. Embedded metadata extends/overrides the metadata of the associated prototype if one such exists. If no prototype is present, the embedded metadata is the only kind available to the consumer.
- The SData-defined metadata set (presented in this document) can be augmented by contractspecific metadata elements.
- All SData entities expressed in JSON MUST be valid JSON documents, whether containing metadata extensions or not.