У меня есть один шаблон схемы Json, который содержит массив объектов.И мне нужно проверить ввод Json с этим шаблоном.Но я хочу, чтобы это не зависело от порядка для объекта в массиве.
И ниже у нас есть массив из 3 различных объектов в шаблоне, т.е. abs, endpoint и dispatch.Я хочу удалить зависимость порядка отсюда.Я могу указать порядок элементов в схеме ввода Json.Это не должно зависеть от шаблона.Я использую шаблон js узла 'ajv' для проверки ввода Json с данными шаблона.Любая помощь будет оценена.Спасибо.
Attached template and input json.
Json Template
var schema1 = {
"additionalProperties" : {
"type" : "integer"
},
"properties": {
"name": { "type": "string" },
"description": { "type": "string" },
"services": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"type": { "type": "string", "const" :"abs" },
"id": { "type": "string" },
"name": { "type": "string" },
"appId": { "type": "string" },
"endpoint": { "type": "string" }
},
//"additionalProperties": false
"required": [ "type","id", "name","appId", "endpoint"]
},
{
"type": "object",
"properties": {
"type": { "type": "string", "const" :"endpoint" },
"id": { "type": "string" },
"name": { "type": "string" },
"appPassword": { "type": "string" },
"appId": { "type": "string" },
"endpoint": { "type": "string" }
},
//"additionalProperties": false,
"required": [ "type","id", "name","appPassword","appId", "endpoint"]
}
,
{
"type": "object",
"properties": {
"type": { "type": "string", "const" :"dispatch" },
"serviceIds" : {"type":"array", "items": [{ "type": "string" }]},
"name": { "type": "string" },
"appId": { "type": "string" },
"authoringKey": { "type": "string" },
"version": { "type": "string" },
"region": { "type": "string" },
"id": { "type": "string" }
},
//"additionalProperties": false
"required": [ "type","serviceIds", "name","appId","authoringKey","version","region", "id"]
}
]
}
}
};
Input Json :
{
"name": "ScorpioBot-development",
"description": "",
"services": [
{
"type": "endpoint",
"id": "1",
"name": "development",
"appId": "test",
"appPassword": "test",
"endpoint": "http://localhost:3978"
},
{
"type": "abs",
"id": "49",
"name": "test-development",
"appId": "12323",
"endpoint": "http://localhost:3978/"
},
{
"type": "endpoint",
"id": "11",
"name": "development",
"appId": "test1",
"appPassword": "test1",
"endpoint": "http://localhost:3978"
},
{
"type": "dispatch",
"serviceIds": [
"general"
],
"name": "test_Dispatch",
"appId": "test",
"authoringKey": "1234,
"version": "Dispatch",
"region": "test",
"id": "dispatch"
}
]
}` {
"name": "ScorpioBot-development",
"description": "",
"services": [
{
"type": "endpoint",
"id": "1",
"name": "development",
"appId": "test",
"appPassword": "test",
"endpoint": "http://localhost:3978"
},
{
"type": "abs",
"id": "49",
"name": "test-development",
"appId": "12323",
"endpoint": "http://localhost:3978/"
},
{
"type": "endpoint",
"id": "11",
"name": "development",
"appId": "test1",
"appPassword": "test1",
"endpoint": "http://localhost:3978"
},
{
"type": "dispatch",
"serviceIds": [
"general"
],
"name": "test_Dispatch",
"appId": "test",
"authoringKey": "1234,
"version": "Dispatch",
"region": "test",
"id": "dispatch"
}
]
}`