I am currently facing a problem in parsing my json schema with Json.NET. My schema is composed by an array, whose items can be of two different types, as described in the example below:
"Operations": {
"type": "array",
"id": "Operations",
"required": true,
"items": {
"type": [
{
"type": "object",
"properties": {
"Sale_ID": {
"type": "number",
"id": "Sale_ID",
"required": false
},
},
"additionalProperties": false
},
{
"type": "object",
"properties": {
"Purchase_ID": {
"type": "number",
"id": "Purchase_ID",
"required": false
},
},
"additionalProperties": false
}
This schema was validated in multiple validators, always with success. I’m trying to parse it as a JsonSchema:
JsonSchema js = JsonSchema.Parse(schemaAsString);
However, I get a JsonReaderException:
Exception JSON schema type string token, got StartObject
I’m guessing this happens because my item type is not a string. I would like to know if it is possible to define non-string types in Json.NET, or if this is a known issue/limitation.
Json.NETdoes not support complex schemas in thetypeproperty.Update:
Json.NET Schema now has full support for Draft 3 and Draft 4, which includes support for complex schemas in the type property.