json 스키마를 정의하여 다른 모양의 객체 목록을 보유하는 방법을 읽었습니다 : 사람, 주소, 차량. 연구의 일환으로 도움이되는 추가 정보가 제안 된 게시물로 이동하게되었습니다. 예 : "uniqueitems"추가 : 목록에 중복이 없도록 true.http://www.jsonschemavalidator.net/이 "uniqueitems"을 준수하지 않는 것처럼 보입니다 : true 또는 "additionalProperties": false
내 스키마와 JSON 데이터의 유효성을 검사에 사이트 매우 유용 http://www.jsonschemavalidator.net/를 발견했습니다하지만 난 모두"additionalProperties": false
및
"uniqueitems": true
잘못 뭘하는지 알아낼 수 없습니다
내 샘플 스키마 및 데이터는 다음과 같습니다.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "an array of Insurable Items",
"type": "array",
"items": {
"type": "object",
"OneOf": [
{
"type": "object",
"description": "A Person",
"properties": {
"person": {
"type": "object",
"$ref": "#/definitions/person"
}
},
"required": [
"person"
],
"additionalProperties": false
},
{
"type": "object",
"description": "An Address",
"properties": {
"address": {
"type": "object",
"$ref": "#/definitions/address"
}
},
"required": [
"address"
],
"additionalProperties": false
},
{
"type": "object",
"description": "A Vehicle",
"properties": {
"vehicle": {
"type": "object",
"$ref": "#/definitions/vehicle"
}
},
"required": [
"vehicle"
],
"additionalProperties": false
}
],
"uniqueitems": true
},
"definitions": {
"person": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"title": {
"type": "string"
},
"firstname": {
"type": "string"
},
"lastname": {
"type": "string"
},
"dateofbirth": {
"type": "string"
},
"employmentstatus": {
"type": "string"
},
"occupation": {
"type": "string"
}
},
"additionalProperties": false
},
"address": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"line1": {
"type": "string"
},
"line2": {
"type": "string"
},
"line3": {
"type": "string"
},
"line4": {
"type": "string"
},
"line5": {
"type": "string"
},
"postcode": {
"type": "string"
}
},
"additionalProperties": false
},
"vehicle": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"vehiclecode": {
"type": "string"
},
"registrationyear": {
"type": "string"
},
"registrationletter": {
"type": "string"
},
"registrationnumber": {
"type": "string"
},
"description": {
"type": "string"
}
},
"additionalProperties": false
}
}
}
데이터 :
01 당신이이 http://www.jsonschemavalidator.net/ 스키마 검증에 복사하면 23,516,[
{
"person": {
"id": "123456789-01",
"title": "Mr",
"firstname": "Joe",
"lastname": "blogs"
},
"badadditional": "thing"
},
{
"address": {
"id": "123456789-A",
"line1": "1 The Mall",
"line2": "Westminster",
"line3": "London",
"postcode": "SW1A 1AA"
}
},
{
"address": {
"id": "123456789-A",
"line1": "1 The Mall",
"line2": "Westminster",
"line3": "London",
"postcode": "SW1A 1AA"
}
},
{
"vehicle": {
"id": "123456789-01-01",
"vehiclecode": "string",
"registrationyear": "string",
"registrationletter": "string",
"registrationnumber": "string",
"description": "string",
"badadditional": "other thing"
}
}
]
, 그것은
"badadditional": "thing"
및
"badadditional": "other thing"
의 존재와 중복 주소 객체에도 불구하고 문제를보고하지 않습니다.
저는 (다른 사람들에게) stackoverflow [태그가있는 json.net]을 검색했습니다. http://grokbase.com, http://json-schema.org 그리고 draft-04로 작업 중입니다.
나는 또한 https://jsonschemalint.com/#/version/draft-04/markup/json을 시도했지만 역시 불만을 제기하지 않습니다.
다른 사람이 다른 유효성 검사기, json 스키마 설명서 및 예제를 가리키며 나를 분명히 알 수 있습니까?
감사합니다. Jason. 나는 그것이 어리석은 무엇인가했기를 바라고 있었다. 이제 리소스를 다시 살펴 보겠습니다. 대소 문자를 구분합니다. –
그게 치료를 작동합니다 - 감사합니다 Logged –