Check JSON for schema in .Net

I know that there is a proposed standard for checking JSON schema, is there an implementation in .Net?

+4
source share
3 answers

Json.NET has this functionality.

+4
source

A free alternative to open source Json.NET is NJsonSchema (JSON 4 schema project).

+5
source

Add the Newtonsoft Json NuGet package to your solution. Add a function below and pass the circuit and your json answer in the line below the function.

public void ValidateSchema(JsonSchema JSchema, string JsonString) { JsonString = JsonString.Replace("\"", "'"); var ArrJobj = JArray.Parse(JsonString); foreach (JObject jo in ArrJobj) { if (!jo.IsValid(JSchema)) throw new Exception("Schems Validation failed"); } } 

Hope this helps

0
source

Source: https://habr.com/ru/post/1306449/


All Articles