Validating JSON Messages with JSON-Schema

Validating JSON Messages

with JSON-Schema

Interop North Spring - Shanghai 14 19 May 2017 - Laurent MICHEL

1

Use Case: SVOM: a GRB Monitor

French Ground Segment

Pipeline (Python)

REST

{json}

Pipeline (Java)

¡ñ

Heterogeneous system

¡ð Multiple Agents

¡ð Multiple institutes

¡ð Multiple languages

REST

Pipeline (Go)

{json}

{json}

REST

{json}

¡ñ

Continuous integration

¡ð JSON messages

must be tested

against specified

schemes

Interop North Spring - Shanghai 14 19 May 2017 - Laurent MICHEL

Database (C)

REST

2

JSON Schema Home Page

Useful for the VO?

Screenshot

Interop North Spring - Shanghai 14 19 May 2017 - Laurent MICHEL

3

What is a JSON Schema

¡ñ A JSON schema is a JSON object

¡ð

¡ð

¡ð

JSON-schema components are also JSON-schemes

Controlled vocabulary

Compliant with a meta-schema

¡ñ Can be interpreted by a processor to validate

message contents

¡ð

¡ð

Simple type validation

Complex type validation

Schema

Valid

Not valid

{}

Any JSON entity

nothing

{ "type": "string" }

¡°This is a string¡±

45

{ ¡°key¡±, ¡°this is a string¡±}

Interop North Spring - Shanghai 14 19 May 2017 - Laurent MICHEL

4

Typical Schema Structure

{

¡ñ

"definitions": {

"address": {

"type": "object",

"properties": {

"street_address": {

"type": "string"

},

"city": {

"type": "string"

},

"state": {

"type": "string"

}

},

"required": [

"street_address",

"city",

"state"

]

}

},

Dictionary of definitions

¡ð Components

"type": "object",

¡ñ

"properties": {

"billing_address": {

"$ref": "#/definitions/address"

},

"shipping_address": {

"$ref": "#/definitions/address"

Root object structure

¡ð Object or array

}

Interop North Spring - Shanghai 14 19 May 2017 - Laurent MICHEL

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download