Unknown macro: {next_previous_link3}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

The following specification defines the Data Mapper JSON schema of WSO2 ESB. It is intended to be the authoritative specification. Implementations of schemas for the Data Mapper mediator must adhere to this.

Schema declaration

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.

{ “$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"}

Complex types

WSO2 ESB Data Mapper schema supports the following complex types: object and array. 

Object

Object uses the type name “object”, and supports the following attributes.

  • “id” : a JSON string declaring a unique identifier for the object (required).
  • “type”: a JSON string providing the element type.
  • “description”: a JSON string providing documentation to the user of this schema.
  • “properties”: a JSON object listing fields (required). Each field is a JSON object.
  • “attributes”: a JSON object listing XML attribute fields. Each field is a JSON object.

Arrays

Arrays use the type name "array", and support a single attribute out of the following.
  • “items”: the schema representing the items of the of the array.
  • “id” : a JSON string declaring a unique identifier for the object (required).
  • “attributes”: a JSON object listing XML attribute fields. Each field is a JSON object.
  • “description”: a JSON string providing documentation to the user of this schema

For example, an array of an object containing a field named firstname is declared as shown below.

 

 

 

{
"type": "array", 
"items": [
{
           	"id":"http://jsonschema.net/employee/0",
           	"type":"object",
           	"properties":{
“firstname":{
                 	"id":"http://jsonschema.net/employee/0/firstname",
                 	"type":"string"
              	}
}
}]
}

Defining WSO2 schemas to Represent XML Payload

 

 

 

 

  • No labels