Skip to main content
Skip table of contents

Validate JSON

This policy can be used to validate whether a request or response conforms to the schema specified. The policy takes the JSON schema based on the specification defined in the article provided in the following link: http://json-schema.org/latest/json-schema-core.html.The validation will be successful if the payload conforms to the JSON schema specified in the policy configuration.


Figure 1: Validate JSON policy with a sample schema

Example:

Given below is a basic JSON schema to be specified in the policy configuration.

Basic JSON schema

CODE
{
   "$schema": "http://json-schema.org/draft-04/schema#",
   "title": "Product",
   "description": "A product from Acme's catalog",
   "type": "object",
	
   "properties": {
	
      "id": {
         "description": "The unique identifier for a product",
         "type": "integer"
      },
		
      "name": {
         "description": "Name of the product",
         "type": "string"
      },
		
      "price": {
         "type": "number",
         "minimum": 0,
         "exclusiveMinimum": true
      }
   },
	
   "required": ["id", "name", "price"]
}

Given below is a sample payload which conforms to the JSON schema specified.

Payload

CODE
{ "id": 2, "name": "An ice sculpture", "price": 12.50}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.