Reputation: 495
here is my json schema file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "BootNotificationResponse",
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"Accepted",
"Pending",
"Rejected"
]
},
"currentTime": {
"type": "string",
"format": "date-time"
},
"interval": {
"type": "number"
}
},
"additionalProperties": false,
"required": [
"status",
"currentTime",
"interval"
]
}
and I tried codes
string file = File.ReadAllText(@"../../json/BootNotificationResponse.json");
Console.WriteLine(file);
JsonSchema.Parse(file);
file points json schema location.
there was exception.
System.ArgumentException: Can not convert Array to Boolean.
I followed example code site Newtonsoft.
How can I solved this error?
please comment
thanks.
Upvotes: 2
Views: 2184
Reputation: 777
Use NewtonSoft's Online Schema Validator and you will see "Required properties are missing from object: status, currentTime, interval." You will need to remove the following from your schema to make it work for this implementation.
"required": [
"status",
"currentTime",
"interval"
]
or if you want to fix it you will need to update the JSON schema to include the definitions like
{
'$schema': 'http://json-schema.org/draft-04/schema#',
'title': 'BootNotificationResponse',
'definitions': {
'BootNotificationResponse': {
'type': 'object',
'properties': {
'status': {
'type': 'string',
'enum': [
'Accepted',
'Pending',
'Rejected'
]
},
'currentTime': {
'type': 'string',
'format': 'date-time'
},
'interval': {
'type': 'number'
}
},
'additionalProperties': false,
'required': [
'status',
'currentTime',
'interval'
]
}
}
}
Upvotes: 3