177.3. 例
以下の JSON スキーマがあるとします。
myschema.json
{ "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {}, "id": "my-schema", "properties": { "id": { "default": 1, "description": "An explanation about the purpose of this instance.", "id": "/properties/id", "title": "The id schema", "type": "integer" }, "name": { "default": "A green door", "description": "An explanation about the purpose of this instance.", "id": "/properties/name", "title": "The name schema", "type": "string" }, "price": { "default": 12.5, "description": "An explanation about the purpose of this instance.", "id": "/properties/price", "title": "The price schema", "type": "number" } }, "required": [ "name", "id", "price" ], "type": "object" }
以下の Camel ルートを使用して受信 JSON を検証できます。myschema.json
はクラスパスから読み込まれます。
from("direct:start") .to("json-validator:myschema.json") .to("mock:end")