如何使用JSON.NET Schema或NJSONSchema根据Draft v4验证JSON Schema? [英] How to validate JSON Schema according to Draft v4 using JSON.NET Schema or NJSONSchema?

查看:155
本文介绍了如何使用JSON.NET Schema或NJSONSchema根据Draft v4验证JSON Schema?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究 JSON.NET架构

I have been looking into both JSON.NET Schema and NJsonSchema ... Both dont seem to have any propert / method that identifies if JSON Schema is a valid JSON Schema and in accordance with draft v4 Compatible.

难道只有一个异常会识别模式是否有效,即使有效,我将如何检查其v4草案可修改性?

Is it that only an exception that will identify if a schema is valid, and even if its vaid, how will i check that its draft v4 Comatible?

推荐答案

您可以使用描述JSON模式的JSON模式,并使用它来验证JSON.

You can use a JSON schema that describes JSON schema and use that to validate the JSON.

您可以在此处找到副本- http://www.jsonschemavalidator.net/api/jsonschemastore/schema?schemaUrl=schema-draft-v4

You can find a copy here - http://www.jsonschemavalidator.net/api/jsonschemastore/schema?schemaUrl=schema-draft-v4

string draftV4SchemaJson = @"{}"; // replace with content from http://www.jsonschemavalidator.net/api/jsonschemastore/schema?schemaUrl=schema-draft-v4

JSchema draftV4Schema = JSchema.Parse(draftV4SchemaJson);

JObject yourSchemaJson = JObject.Parse(@"{}"); // your schema

bool valid = yourSchemaJson.IsValid(draftV4Schema);

这篇关于如何使用JSON.NET Schema或NJSONSchema根据Draft v4验证JSON Schema?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆