Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A schema is represented in JSON by one of:

  • A JSON string, naming a defined type.
  • A JSON object, of the form: {"type": "typeName" ...attributes...}, where typeName is either a primitive or a derived type name, as defined below. 
  • A JSON array, representing a union of embedded types.

WSO2 ESB Data Mapper schema should start with the $schema attribute with the WSO2 Data Mapper schema version. For example: { “$schema”:”http://wso2-data-mapper-json-schema/1.0v”}

 

Also, it can contain following optional attributes that will define more information about the schema.

  • “id”: a JSON string declaring a unique identifier for the schema.
  • “title”: a JSON string defining the root element name.
  • “description”: a JSON string providing a detailed description about the schema.
  • “type”: a JSON string providing the element type.
  • “namespaces”: a JSON array of JSON objects defining namespaces and prefix values used in the schema as shown in the following example.

Code Block
languagejs
{ “$schema” : ”http://wso2-data-mapper-json-schema/1.0v”,
“id”:”http://wso2-data-mapper-json-schema-sample-o1”,
“title”:”RootElement”,
"type":"object",
“description”:”This schema represent any form of object without any restriction” ,
"namespaces":[
{ "prefix":"ns1", "url":"http://ns1.com"},
{"prefix":"ns2", "url":"http://ns2.com"}]
}

Primitive types

 

Primitive types have no specified attributes. The set of primitive type names are as follows.

  • null: no value
  • boolean: a binary value
  • integer: integer value
  • number: rational numbers
  • string: unicode character sequence

Primitive type names are also defined type names. Thus, for example, the schema "string" is equivalent to: {"type": "string"}