【发布时间】:2014-09-04 23:27:36
【问题描述】:
如何在 JsonSchema 中设置多种类型。 下面示例中的描述字段我希望它是 JsonSchemaType.String 或 JsonSchemaType.null。
{PropertyNames.Id, new JsonSchema { Type = JsonSchemaType.Integer, Required = true }},
{PropertyNames.Description, new JsonSchema { Type = JsonSchemaType.String, Required = true }}
另外,我有一个由整数和浮点数组成的数组。
result[PropertyNames.Metrics] = new JsonSchema { Type = JsonSchemaType.Array, Required = true, Items = new List<JsonSchema> { new JsonSchema() { Type = JsonSchemaType.Integer } } };
验证失败,因为它需要整数但接收浮点数。我可以做一些像 Type = JsonSchemaType.Integer "or" JsonSchemaType.Float
【问题讨论】:
-
不要将您的 Google 搜索放在问题的标题中。 把你要问的问题放在标题中。
标签: json schema json.net jsonschema json-schema-validator