-Documentation
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonSchema" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>Json.NET supports the JSON Schema standard via the <codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchema</codeEntityReference>
|
||||||
|
and <codeEntityReference>T:Newtonsoft.Json.JsonValidatingReader</codeEntityReference> classes and sits under
|
||||||
|
the <codeEntityReference>N:Newtonsoft.Json.Schema</codeEntityReference> namespae.</para>
|
||||||
|
<para>JSON Schema is used to validate the structure and
|
||||||
|
data types of a piece of JSON, similar to XML Schema for XML. Read more about JSON Schema at
|
||||||
|
<externalLink>
|
||||||
|
<linkText>json-schema.org</linkText>
|
||||||
|
<linkUri>http://json-schema.org/</linkUri>
|
||||||
|
<linkTarget>_blank</linkTarget>
|
||||||
|
</externalLink>.</para>
|
||||||
|
</introduction>
|
||||||
|
<!-- Optional procedures followed by optional code example but must have
|
||||||
|
at least one procedure or code example -->
|
||||||
|
<section>
|
||||||
|
<title>Validating with JSON Schema</title>
|
||||||
|
<content>
|
||||||
|
<para>The simplest way to check if JSON is valid is to load the JSON into a JObject or JArray and then
|
||||||
|
use the <codeEntityReference>M:Newtonsoft.Json.Schema.Extensions.IsValid(Newtonsoft.Json.Linq.JToken,Newtonsoft.Json.Schema.JsonSchema)</codeEntityReference>
|
||||||
|
method with the JSON Schema.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonSchemaTests.cs" region="IsValidBasic" title="Validate JSON with IsValid" />
|
||||||
|
|
||||||
|
<para>To get validation error messages use the
|
||||||
|
<codeEntityReference>M:Newtonsoft.Json.Schema.Extensions.IsValid(Newtonsoft.Json.Linq.JToken,Newtonsoft.Json.Schema.JsonSchema,System.Collections.Generic.IList{System.String}@)</codeEntityReference>
|
||||||
|
or
|
||||||
|
<codeEntityReference>M:Newtonsoft.Json.Schema.Extensions.Validate(Newtonsoft.Json.Linq.JToken,Newtonsoft.Json.Schema.JsonSchema,Newtonsoft.Json.Schema.ValidationEventHandler)</codeEntityReference>
|
||||||
|
overloads.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonSchemaTests.cs" region="IsValidMessages" title="Validate JSON with IsValid" />
|
||||||
|
|
||||||
|
<para>Internally IsValid uses <codeEntityReference>T:Newtonsoft.Json.JsonValidatingReader</codeEntityReference>
|
||||||
|
to perform the JSON Schema validation. To skip the overhead of loading JSON into a JObject/JArray, validating
|
||||||
|
the JSON and then deserializing the JSON into a class, JsonValidatingReader can be used with JsonSerializer to validate JSON while the object is being deserialized.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonSchemaTests.cs" region="JsonValidatingReader" title="Validate JSON with JsonValidatingReader" />
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title>Creating JSON Schemas</title>
|
||||||
|
<content>
|
||||||
|
|
||||||
|
<para>The simplest way to get a <codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchema</codeEntityReference> object is to load it from a string or a file.</para>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonSchemaTests.cs" region="LoadJsonSchema" title="Creating JSON Schemas from strings or files" />
|
||||||
|
|
||||||
|
<para>It is also possible to create JsonSchema objects in code.</para>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonSchemaTests.cs" region="ManuallyCreateJsonSchema" title="Create new JSON Schemas in code" />
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<relatedTopics>
|
||||||
|
<codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchema</codeEntityReference>
|
||||||
|
<codeEntityReference>T:Newtonsoft.Json.JsonValidatingReader</codeEntityReference>
|
||||||
|
</relatedTopics>
|
||||||
|
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<introduction>
|
<introduction>
|
||||||
<para>LINQ to JSON is an API for working with JSON objects.
|
<para>LINQ to JSON is an API for working with JSON objects.
|
||||||
The API has been designed with LINQ in mind to enable to quick querying
|
It has been designed with LINQ in mind to enable to quick querying
|
||||||
and creation of JSON objects. LINQ to JSON sits under the
|
and creation of JSON objects. LINQ to JSON sits under the
|
||||||
<codeEntityReference>N:Newtonsoft.Json.Linq</codeEntityReference>
|
<codeEntityReference>N:Newtonsoft.Json.Linq</codeEntityReference>
|
||||||
namespace.</para>
|
namespace.</para>
|
||||||
|
|||||||
+3
-2
@@ -15,12 +15,13 @@
|
|||||||
<Topic id="ReducingSerializedJSONSize" visible="True" title="Reducing Serialized JSON Size" />
|
<Topic id="ReducingSerializedJSONSize" visible="True" title="Reducing Serialized JSON Size" />
|
||||||
<Topic id="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
<Topic id="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
||||||
</Topic>
|
</Topic>
|
||||||
<Topic id="LINQtoJSON" visible="True" isExpanded="true" title="LINQ to JSON">
|
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
||||||
<Topic id="ParsingLINQtoJSON" visible="True" isSelected="true" title="Parsing JSON" />
|
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
||||||
<Topic id="CreatingLINQtoJSON" visible="True" title="Creating JSON" />
|
<Topic id="CreatingLINQtoJSON" visible="True" title="Creating JSON" />
|
||||||
<Topic id="QueryingLINQtoJSON" visible="True" title="Querying JSON with LINQ" />
|
<Topic id="QueryingLINQtoJSON" visible="True" title="Querying JSON with LINQ" />
|
||||||
<Topic id="SelectToken" visible="True" title="Querying JSON with SelectToken" />
|
<Topic id="SelectToken" visible="True" title="Querying JSON with SelectToken" />
|
||||||
</Topic>
|
</Topic>
|
||||||
|
<Topic id="JsonSchema" visible="True" isSelected="true" title="Validating JSON" />
|
||||||
<Topic id="ReadingWritingJSON" visible="True" title="Basic Reading and Writing JSON" />
|
<Topic id="ReadingWritingJSON" visible="True" title="Basic Reading and Writing JSON" />
|
||||||
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
||||||
</Topics>
|
</Topics>
|
||||||
@@ -141,6 +141,9 @@
|
|||||||
<None Include="ContractResolver.aml" />
|
<None Include="ContractResolver.aml" />
|
||||||
<None Include="ConvertingJSONandXML.aml" />
|
<None Include="ConvertingJSONandXML.aml" />
|
||||||
<None Include="CreatingLINQtoJSON.aml" />
|
<None Include="CreatingLINQtoJSON.aml" />
|
||||||
|
<None Include="Copy of ContractResolver.aml" />
|
||||||
|
<None Include="JsonSchema.aml" />
|
||||||
|
<None Include="JsonSchema.aml" />
|
||||||
<None Include="ParsingLINQtoJSON.aml" />
|
<None Include="ParsingLINQtoJSON.aml" />
|
||||||
<None Include="QueryingLINQtoJSON.aml" />
|
<None Include="QueryingLINQtoJSON.aml" />
|
||||||
<None Include="ReadingWritingJSON.aml" />
|
<None Include="ReadingWritingJSON.aml" />
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ using File = System.IO.File;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.Documentation
|
namespace Newtonsoft.Json.Tests.Documentation
|
||||||
{
|
{
|
||||||
|
public static class File
|
||||||
|
{
|
||||||
|
public static StreamReader OpenText(string path)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LinqToJsonTests
|
public class LinqToJsonTests
|
||||||
{
|
{
|
||||||
public void LinqToJsonBasic()
|
public void LinqToJsonBasic()
|
||||||
@@ -218,14 +226,6 @@ namespace Newtonsoft.Json.Tests.Documentation
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class File
|
|
||||||
{
|
|
||||||
public static StreamReader OpenText(string path)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LinqToJsonReadObject()
|
public void LinqToJsonReadObject()
|
||||||
{
|
{
|
||||||
#region LinqToJsonReadObject
|
#region LinqToJsonReadObject
|
||||||
|
|||||||
@@ -117,6 +117,7 @@
|
|||||||
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
||||||
<Compile Include="Converters\VersionConverterTests.cs" />
|
<Compile Include="Converters\VersionConverterTests.cs" />
|
||||||
<Compile Include="Documentation\ConvertingJsonAndXmlTests.cs" />
|
<Compile Include="Documentation\ConvertingJsonAndXmlTests.cs" />
|
||||||
|
<Compile Include="Documentation\JsonSchemaTests.cs" />
|
||||||
<Compile Include="Documentation\ReadingAndWritingJsonTests.cs" />
|
<Compile Include="Documentation\ReadingAndWritingJsonTests.cs" />
|
||||||
<Compile Include="Documentation\LinqToJsonTests.cs" />
|
<Compile Include="Documentation\LinqToJsonTests.cs" />
|
||||||
<Compile Include="Documentation\SerializationTests.cs" />
|
<Compile Include="Documentation\SerializationTests.cs" />
|
||||||
|
|||||||
@@ -72,5 +72,5 @@ using System.Security;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
#if !PocketPC
|
#if !PocketPC
|
||||||
[assembly: AssemblyFileVersion("4.5.8.15212")]
|
[assembly: AssemblyFileVersion("4.5.8.15213")]
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ using System.Security;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
#if !PocketPC
|
#if !PocketPC
|
||||||
[assembly: AssemblyFileVersion("4.5.8.15212")]
|
[assembly: AssemblyFileVersion("4.5.8.15213")]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|||||||
Reference in New Issue
Block a user