Add documentation and split JSON Path into its own documentation section (#1925)
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="ErrorWhenNoMatchQuery" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This sample loads JSON and then queries values from it using <codeEntityReference>Overload:Newtonsoft.Json.Linq.JToken.SelectToken</codeEntityReference>. An error is thrown when part of the JSON path is not found.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Sample</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\ErrorWhenNoMatchQuery.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<title>Sample</title>
|
<title>Sample</title>
|
||||||
<content>
|
<content>
|
||||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Linq\QueryJsonSelectToken.cs" region="Usage" title="Usage" />
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\QueryJsonSelectToken.cs" region="Usage" title="Usage" />
|
||||||
</content>
|
</content>
|
||||||
</section>
|
</section>
|
||||||
</developerConceptualDocument>
|
</developerConceptualDocument>
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<title>Sample</title>
|
<title>Sample</title>
|
||||||
<content>
|
<content>
|
||||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Linq\QueryJsonSelectTokenEscaped.cs" region="Usage" title="Usage" />
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\QueryJsonSelectTokenEscaped.cs" region="Usage" title="Usage" />
|
||||||
</content>
|
</content>
|
||||||
</section>
|
</section>
|
||||||
</developerConceptualDocument>
|
</developerConceptualDocument>
|
||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<title>Sample</title>
|
<title>Sample</title>
|
||||||
<content>
|
<content>
|
||||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Linq\QueryJsonSelectTokenJsonPath.cs" region="Usage" title="Usage" />
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\QueryJsonSelectTokenJsonPath.cs" region="Usage" title="Usage" />
|
||||||
</content>
|
</content>
|
||||||
</section>
|
</section>
|
||||||
</developerConceptualDocument>
|
</developerConceptualDocument>
|
||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<title>Sample</title>
|
<title>Sample</title>
|
||||||
<content>
|
<content>
|
||||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Linq\QueryJsonSelectTokenWithLinq.cs" region="Usage" title="Usage" />
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\QueryJsonSelectTokenWithLinq.cs" region="Usage" title="Usage" />
|
||||||
</content>
|
</content>
|
||||||
</section>
|
</section>
|
||||||
</developerConceptualDocument>
|
</developerConceptualDocument>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="RegexQuery" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This sample loads JSON and then queries values from it using <codeEntityReference>M:Newtonsoft.Json.Linq.JToken.SelectToken(System.String)</codeEntityReference> with a regex JSON Path.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Sample</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\RegexQuery.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="StrictEqualsQuery" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This sample loads JSON and then queries values from it using <codeEntityReference>M:Newtonsoft.Json.Linq.JToken.SelectToken(System.String)</codeEntityReference> with a strict equals JSON Path.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Sample</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\StrictEqualsQuery.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
<topic id="CustomJsonConverterGeneric" revisionNumber="1">
|
<topic id="CustomJsonConverterGeneric" revisionNumber="1">
|
||||||
<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>This sample creates a custom <codeEntityReference>T:Newtonsoft.Json.JsonConverter{T}</codeEntityReference>
|
<para>This sample creates a custom converter from <c>JsonConverter<T></c>
|
||||||
that overrides serialization for the Version property with a custom display string.</para>
|
that overrides serialization for the <c>Version</c> class with a custom display string.</para>
|
||||||
</introduction>
|
</introduction>
|
||||||
<section>
|
<section>
|
||||||
<title>Sample</title>
|
<title>Sample</title>
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@
|
|||||||
<linkTarget>_blank</linkTarget>
|
<linkTarget>_blank</linkTarget>
|
||||||
</externalLink>.</para>
|
</externalLink>.</para>
|
||||||
|
|
||||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\Linq\QueryJsonSelectTokenJsonPath.cs" region="Usage" title="SelectToken With JSONPath" />
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\QueryJsonSelectTokenJsonPath.cs" region="Usage" title="SelectToken With JSONPath" />
|
||||||
</content>
|
</content>
|
||||||
</section>
|
</section>
|
||||||
<section address="SelectTokenLINQ">
|
<section address="SelectTokenLINQ">
|
||||||
|
|||||||
+12
-7
@@ -29,7 +29,7 @@
|
|||||||
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
||||||
<Topic id="JsonNetVsDotNetSerializers" visible="True" title="Json.NET vs .NET Serializers" />
|
<Topic id="JsonNetVsDotNetSerializers" visible="True" title="Json.NET vs .NET Serializers" />
|
||||||
<Topic id="Samples" visible="True" isExpanded="true" title="Samples">
|
<Topic id="Samples" visible="True" isExpanded="true" title="Samples">
|
||||||
<Topic id="d6e185d5-c992-44fc-8d8f-d9acc2bbec2f" visible="True" noFile="true" isExpanded="true" title="Serializing JSON">
|
<Topic id="d6e185d5-c992-44fc-8d8f-d9acc2bbec2f" visible="True" noFile="true" title="Serializing JSON">
|
||||||
<Topic id="SerializeObject" visible="True" title="Serialize an Object" />
|
<Topic id="SerializeObject" visible="True" title="Serialize an Object" />
|
||||||
<Topic id="SerializeCollection" visible="True" title="Serialize a Collection" />
|
<Topic id="SerializeCollection" visible="True" title="Serialize a Collection" />
|
||||||
<Topic id="SerializeDictionary" visible="True" title="Serialize a Dictionary" />
|
<Topic id="SerializeDictionary" visible="True" title="Serialize a Dictionary" />
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
<Topic id="ErrorHandlingEvent" visible="True" title="ErrorHandling setting" />
|
<Topic id="ErrorHandlingEvent" visible="True" title="ErrorHandling setting" />
|
||||||
<Topic id="MaxDepth" visible="True" title="MaxDepth setting" />
|
<Topic id="MaxDepth" visible="True" title="MaxDepth setting" />
|
||||||
<Topic id="CustomJsonConverter" visible="True" title="Custom JsonConverter" />
|
<Topic id="CustomJsonConverter" visible="True" title="Custom JsonConverter" />
|
||||||
<Topic id="CustomJsonConverterGeneric" visible="True" isSelected="true" title="Custom JsonConverter<T>" />
|
<Topic id="CustomJsonConverterGeneric" visible="True" title="Custom JsonConverter<T>" />
|
||||||
<Topic id="CustomContractResolver" visible="True" title="Custom IContractResolver" />
|
<Topic id="CustomContractResolver" visible="True" title="Custom IContractResolver" />
|
||||||
<Topic id="CustomTraceWriter" visible="True" title="Custom ITraceWriter" />
|
<Topic id="CustomTraceWriter" visible="True" title="Custom ITraceWriter" />
|
||||||
<Topic id="SerializeSerializationBinder" visible="True" title="Custom SerializationBinder" />
|
<Topic id="SerializeSerializationBinder" visible="True" title="Custom SerializationBinder" />
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
<Topic id="NamingStrategySkipDictionaryKeys" visible="True" title="Configure NamingStrategy dictionary serialization" />
|
<Topic id="NamingStrategySkipDictionaryKeys" visible="True" title="Configure NamingStrategy dictionary serialization" />
|
||||||
<Topic id="NamingStrategySkipSpecifiedNames" visible="True" title="Configure NamingStrategy property name serialization" />
|
<Topic id="NamingStrategySkipSpecifiedNames" visible="True" title="Configure NamingStrategy property name serialization" />
|
||||||
</Topic>
|
</Topic>
|
||||||
<Topic id="68b9fad2-5436-4e35-a734-9b9d751cc3e5" visible="True" noFile="true" title="LINQ to JSON">
|
<Topic id="68b9fad2-5436-4e35-a734-9b9d751cc3e5" visible="True" noFile="true" isExpanded="true" title="LINQ to JSON">
|
||||||
<Topic id="CreateJsonManually" visible="True" title="Create JSON manually" />
|
<Topic id="CreateJsonManually" visible="True" title="Create JSON manually" />
|
||||||
<Topic id="CreateJsonCollectionInitializer" visible="True" title="Create JSON using Collection Initializers" />
|
<Topic id="CreateJsonCollectionInitializer" visible="True" title="Create JSON using Collection Initializers" />
|
||||||
<Topic id="CreateJsonDeclaratively" visible="True" title="Create JSON declaratively with LINQ" />
|
<Topic id="CreateJsonDeclaratively" visible="True" title="Create JSON declaratively with LINQ" />
|
||||||
@@ -114,10 +114,6 @@
|
|||||||
<Topic id="QueryJson" visible="True" title="Querying JSON" />
|
<Topic id="QueryJson" visible="True" title="Querying JSON" />
|
||||||
<Topic id="QueryJsonDynamic" visible="True" title="Querying JSON with dynamic" />
|
<Topic id="QueryJsonDynamic" visible="True" title="Querying JSON with dynamic" />
|
||||||
<Topic id="QueryJsonLinq" visible="True" title="Querying JSON with LINQ" />
|
<Topic id="QueryJsonLinq" visible="True" title="Querying JSON with LINQ" />
|
||||||
<Topic id="QueryJsonSelectToken" visible="True" title="Querying JSON with SelectToken" />
|
|
||||||
<Topic id="QueryJsonSelectTokenEscaped" visible="True" title="Querying JSON with SelectToken and escaped properties" />
|
|
||||||
<Topic id="QueryJsonSelectTokenWithLinq" visible="True" title="Querying JSON with SelectToken and LINQ" />
|
|
||||||
<Topic id="QueryJsonSelectTokenJsonPath" visible="True" title="Querying JSON with JSONPath" />
|
|
||||||
<Topic id="ReadJson" visible="True" title="Read JSON from a file" />
|
<Topic id="ReadJson" visible="True" title="Read JSON from a file" />
|
||||||
<Topic id="WriteToJsonFile" visible="True" title="Write JSON to a file" />
|
<Topic id="WriteToJsonFile" visible="True" title="Write JSON to a file" />
|
||||||
<Topic id="ToObjectComplex" visible="True" title="Convert JSON to Collection" />
|
<Topic id="ToObjectComplex" visible="True" title="Convert JSON to Collection" />
|
||||||
@@ -136,6 +132,15 @@
|
|||||||
<Topic id="ReadJTokenFromBson" visible="True" title="Read from BSON" />
|
<Topic id="ReadJTokenFromBson" visible="True" title="Read from BSON" />
|
||||||
<Topic id="WriteJTokenToBson" visible="True" title="Write as BSON" />
|
<Topic id="WriteJTokenToBson" visible="True" title="Write as BSON" />
|
||||||
</Topic>
|
</Topic>
|
||||||
|
<Topic id="afd615f0-b6b4-40ec-997d-2453e60a25af" visible="True" noFile="true" isExpanded="true" title="JSON Path">
|
||||||
|
<Topic id="QueryJsonSelectToken" visible="True" title="Querying JSON with JSON Path" />
|
||||||
|
<Topic id="QueryJsonSelectTokenEscaped" visible="True" title="Querying JSON with JSON Path and escaped properties" />
|
||||||
|
<Topic id="QueryJsonSelectTokenJsonPath" visible="True" title="Querying JSON with complex JSON Path" />
|
||||||
|
<Topic id="QueryJsonSelectTokenWithLinq" visible="True" title="Querying JSON with JSON Path and LINQ" />
|
||||||
|
<Topic id="RegexQuery" visible="True" title="JSON Path regex operator" />
|
||||||
|
<Topic id="StrictEqualsQuery" visible="True" title="JSON Path strict equals operator" />
|
||||||
|
<Topic id="ErrorWhenNoMatchQuery" visible="True" isSelected="true" title="Throw error when JSON Path not found" />
|
||||||
|
</Topic>
|
||||||
<Topic id="11cded7e-959a-4c6d-a9c9-61d571b75edc" visible="True" noFile="true" title="JSON Schema">
|
<Topic id="11cded7e-959a-4c6d-a9c9-61d571b75edc" visible="True" noFile="true" title="JSON Schema">
|
||||||
<Topic id="JsonSchemaParse" visible="True" title="Parse JSON Schema from JSON" />
|
<Topic id="JsonSchemaParse" visible="True" title="Parse JSON Schema from JSON" />
|
||||||
<Topic id="LoadJsonSchemaFromFile" visible="True" title="Load JSON Schema from a file" />
|
<Topic id="LoadJsonSchemaFromFile" visible="True" title="Load JSON Schema from a file" />
|
||||||
|
|||||||
+10
-6
@@ -8,7 +8,7 @@
|
|||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{fd19f68e-72c8-4576-9775-b4480b0db686}</ProjectGuid>
|
<ProjectGuid>{fd19f68e-72c8-4576-9775-b4480b0db686}</ProjectGuid>
|
||||||
<SHFBSchemaVersion>2015.6.5.0</SHFBSchemaVersion>
|
<SHFBSchemaVersion>2017.9.26.0</SHFBSchemaVersion>
|
||||||
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
|
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
|
||||||
Studio adds them anyway -->
|
Studio adds them anyway -->
|
||||||
<AssemblyName>Documentation</AssemblyName>
|
<AssemblyName>Documentation</AssemblyName>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<ProjectSummary>
|
<ProjectSummary>
|
||||||
</ProjectSummary>
|
</ProjectSummary>
|
||||||
<MissingTags>Summary, Parameter, Returns, AutoDocumentCtors, Namespace, TypeParameter, AutoDocumentDispose</MissingTags>
|
<MissingTags>Summary, Parameter, Returns, AutoDocumentCtors, Namespace, TypeParameter, AutoDocumentDispose</MissingTags>
|
||||||
<VisibleItems>InheritedMembers, InheritedFrameworkMembers, Protected, SealedProtected, ProtectedInternalAsProtected</VisibleItems>
|
<VisibleItems>InheritedMembers, InheritedFrameworkMembers, Protected, SealedProtected, ProtectedInternalAsProtected, EditorBrowsableNever, NonBrowsable</VisibleItems>
|
||||||
<HtmlHelp1xCompilerPath>
|
<HtmlHelp1xCompilerPath>
|
||||||
</HtmlHelp1xCompilerPath>
|
</HtmlHelp1xCompilerPath>
|
||||||
<HtmlHelp2xCompilerPath>
|
<HtmlHelp2xCompilerPath>
|
||||||
@@ -97,13 +97,19 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="icons\favicon.ico" />
|
<Content Include="icons\favicon.ico" />
|
||||||
|
<None Include="Samples\JsonPath\StrictEqualsQuery.aml" />
|
||||||
|
<None Include="Samples\JsonPath\RegexQuery.aml" />
|
||||||
|
<None Include="Samples\JsonPath\QueryJsonSelectTokenWithLinq.aml" />
|
||||||
|
<None Include="Samples\JsonPath\QueryJsonSelectTokenJsonPath.aml" />
|
||||||
|
<None Include="Samples\JsonPath\QueryJsonSelectTokenEscaped.aml" />
|
||||||
|
<None Include="Samples\JsonPath\QueryJsonSelectToken.aml" />
|
||||||
|
<None Include="Samples\JsonPath\ErrorWhenNoMatchQuery.aml" />
|
||||||
<None Include="Samples\Serializer\CustomJsonConverterGeneric.aml" />
|
<None Include="Samples\Serializer\CustomJsonConverterGeneric.aml" />
|
||||||
<None Include="Samples\Serializer\NamingStrategyAttributes.aml" />
|
<None Include="Samples\Serializer\NamingStrategyAttributes.aml" />
|
||||||
<None Include="Samples\Serializer\NamingStrategySnakeCase.aml" />
|
<None Include="Samples\Serializer\NamingStrategySnakeCase.aml" />
|
||||||
<None Include="Samples\Serializer\NamingStrategySkipSpecifiedNames.aml" />
|
<None Include="Samples\Serializer\NamingStrategySkipSpecifiedNames.aml" />
|
||||||
<None Include="Samples\Serializer\NamingStrategySkipDictionaryKeys.aml" />
|
<None Include="Samples\Serializer\NamingStrategySkipDictionaryKeys.aml" />
|
||||||
<None Include="Samples\Serializer\NamingStrategyCamelCase.aml" />
|
<None Include="Samples\Serializer\NamingStrategyCamelCase.aml" />
|
||||||
<None Include="Samples\Linq\QueryJsonSelectTokenEscaped.aml" />
|
|
||||||
<None Include="Samples\Serializer\JsonConstructorAttribute.aml" />
|
<None Include="Samples\Serializer\JsonConstructorAttribute.aml" />
|
||||||
<None Include="Samples\Json\ReadMultipleContentWithJsonReader.aml" />
|
<None Include="Samples\Json\ReadMultipleContentWithJsonReader.aml" />
|
||||||
<None Include="Samples\Serializer\SerializeImmutableCollections.aml" />
|
<None Include="Samples\Serializer\SerializeImmutableCollections.aml" />
|
||||||
@@ -115,7 +121,6 @@
|
|||||||
<None Include="Samples\Serializer\DeserializeExtensionData.aml" />
|
<None Include="Samples\Serializer\DeserializeExtensionData.aml" />
|
||||||
<None Include="Samples\Serializer\DeserializeDateFormatString.aml" />
|
<None Include="Samples\Serializer\DeserializeDateFormatString.aml" />
|
||||||
<None Include="Samples\Serializer\DefaultSettings.aml" />
|
<None Include="Samples\Serializer\DefaultSettings.aml" />
|
||||||
<None Include="Samples\Linq\QueryJsonSelectTokenJsonPath.aml" />
|
|
||||||
<None Include="Samples\Linq\MergeJson.aml" />
|
<None Include="Samples\Linq\MergeJson.aml" />
|
||||||
<None Include="Samples\Linq\JTokenAnnotation.aml" />
|
<None Include="Samples\Linq\JTokenAnnotation.aml" />
|
||||||
<None Include="Samples\Json\CustomJsonWriter.aml" />
|
<None Include="Samples\Json\CustomJsonWriter.aml" />
|
||||||
@@ -142,8 +147,6 @@
|
|||||||
<None Include="Samples\Linq\SerializeWithLinq.aml" />
|
<None Include="Samples\Linq\SerializeWithLinq.aml" />
|
||||||
<None Include="Samples\Linq\ReadJTokenFromBson.aml" />
|
<None Include="Samples\Linq\ReadJTokenFromBson.aml" />
|
||||||
<None Include="Samples\Linq\ReadJson.aml" />
|
<None Include="Samples\Linq\ReadJson.aml" />
|
||||||
<None Include="Samples\Linq\QueryJsonSelectTokenWithLinq.aml" />
|
|
||||||
<None Include="Samples\Linq\QueryJsonSelectToken.aml" />
|
|
||||||
<None Include="Samples\Linq\QueryJsonLinq.aml" />
|
<None Include="Samples\Linq\QueryJsonLinq.aml" />
|
||||||
<None Include="Samples\Linq\QueryJsonDynamic.aml" />
|
<None Include="Samples\Linq\QueryJsonDynamic.aml" />
|
||||||
<None Include="Samples\Linq\QueryJson.aml" />
|
<None Include="Samples\Linq\QueryJson.aml" />
|
||||||
@@ -272,6 +275,7 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="Samples\JsonPath\" />
|
||||||
<Folder Include="icons\" />
|
<Folder Include="icons\" />
|
||||||
<Folder Include="Samples\Xml\" />
|
<Folder Include="Samples\Xml\" />
|
||||||
<Folder Include="Samples\Schema\" />
|
<Folder Include="Samples\Schema\" />
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
#if DNXCORE50
|
||||||
|
using Xunit;
|
||||||
|
using Test = Xunit.FactAttribute;
|
||||||
|
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||||
|
#else
|
||||||
|
using NUnit.Framework;
|
||||||
|
#endif
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
#if NET20
|
||||||
|
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||||
|
#else
|
||||||
|
using System.Linq;
|
||||||
|
#endif
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.JsonPath
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ErrorWhenNoMatchQuery : TestFixtureBase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Example()
|
||||||
|
{
|
||||||
|
#region Usage
|
||||||
|
JArray items = JArray.Parse(@"[
|
||||||
|
{
|
||||||
|
'Name': 'John Doe',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'Name': 'Jane Doe',
|
||||||
|
}
|
||||||
|
]");
|
||||||
|
|
||||||
|
// A true value for errorWhenNoMatch will result in an error if the queried value is missing
|
||||||
|
string result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = (string)items.SelectToken(@"$.[3]['Name']", errorWhenNoMatch: true);
|
||||||
|
}
|
||||||
|
catch (JsonException)
|
||||||
|
{
|
||||||
|
result = "Unable to find result in JSON.";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
Assert.AreEqual("Unable to find result in JSON.", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -41,7 +41,7 @@ using NUnit.Framework;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.JsonPath
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class QueryJsonSelectToken : TestFixtureBase
|
public class QueryJsonSelectToken : TestFixtureBase
|
||||||
+1
-1
@@ -40,7 +40,7 @@ using System.Linq;
|
|||||||
#endif
|
#endif
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.JsonPath
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class QueryJsonSelectTokenEscaped : TestFixtureBase
|
public class QueryJsonSelectTokenEscaped : TestFixtureBase
|
||||||
+1
-1
@@ -40,7 +40,7 @@ using System.Linq;
|
|||||||
#endif
|
#endif
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.JsonPath
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class QueryJsonSelectTokenJsonPath : TestFixtureBase
|
public class QueryJsonSelectTokenJsonPath : TestFixtureBase
|
||||||
+1
-1
@@ -41,7 +41,7 @@ using NUnit.Framework;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.JsonPath
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class QueryJsonSelectTokenWithLinq : TestFixtureBase
|
public class QueryJsonSelectTokenWithLinq : TestFixtureBase
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
#if DNXCORE50
|
||||||
|
using Xunit;
|
||||||
|
using Test = Xunit.FactAttribute;
|
||||||
|
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||||
|
#else
|
||||||
|
using NUnit.Framework;
|
||||||
|
#endif
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
#if NET20
|
||||||
|
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||||
|
#else
|
||||||
|
using System.Linq;
|
||||||
|
#endif
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.JsonPath
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class RegexQuery : TestFixtureBase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Example()
|
||||||
|
{
|
||||||
|
#region Usage
|
||||||
|
JArray packages = JArray.Parse(@"[
|
||||||
|
{
|
||||||
|
'PackageId': 'Newtonsoft.Json',
|
||||||
|
'Version': '11.0.1',
|
||||||
|
'ReleaseDate': '2018-02-17T00:00:00'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'PackageId': 'NUnit',
|
||||||
|
'Version': '3.9.0',
|
||||||
|
'ReleaseDate': '2017-11-10T00:00:00'
|
||||||
|
}
|
||||||
|
]");
|
||||||
|
|
||||||
|
// Find Newtonsoft packages
|
||||||
|
List<JToken> newtonsoftPackages = packages.SelectTokens(@"$.[?(@.PackageId =~ /^Newtonsoft\.(.*)$/)]").ToList();
|
||||||
|
|
||||||
|
foreach (JToken item in newtonsoftPackages)
|
||||||
|
{
|
||||||
|
Console.WriteLine((string) item["PackageId"]);
|
||||||
|
}
|
||||||
|
// Newtonsoft.Json
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
Assert.AreEqual(1, newtonsoftPackages.Count);
|
||||||
|
Assert.AreEqual("Newtonsoft.Json", (string)newtonsoftPackages[0]["PackageId"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
#if DNXCORE50
|
||||||
|
using Xunit;
|
||||||
|
using Test = Xunit.FactAttribute;
|
||||||
|
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||||
|
#else
|
||||||
|
using NUnit.Framework;
|
||||||
|
#endif
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
#if NET20
|
||||||
|
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||||
|
#else
|
||||||
|
using System.Linq;
|
||||||
|
#endif
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.JsonPath
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class StrictEqualsQuery : TestFixtureBase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Example()
|
||||||
|
{
|
||||||
|
#region Usage
|
||||||
|
JArray items = JArray.Parse(@"[
|
||||||
|
{
|
||||||
|
'Name': 'Valid JSON',
|
||||||
|
'Valid': true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'Name': 'Invalid JSON',
|
||||||
|
'Valid': 'true'
|
||||||
|
}
|
||||||
|
]");
|
||||||
|
|
||||||
|
// Use === operator. Compared types must be the same to be valid
|
||||||
|
List<JToken> strictResults = items.SelectTokens(@"$.[?(@.Valid === true)]").ToList();
|
||||||
|
|
||||||
|
foreach (JToken item in strictResults)
|
||||||
|
{
|
||||||
|
Console.WriteLine((string)item["Name"]);
|
||||||
|
}
|
||||||
|
// Valid JSON
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
Assert.AreEqual(1, strictResults.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
#if NET20
|
||||||
|
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||||
|
#else
|
||||||
|
using System.Linq;
|
||||||
|
#endif
|
||||||
|
using System.Text;
|
||||||
|
#if DNXCORE50
|
||||||
|
using Xunit;
|
||||||
|
using Test = Xunit.FactAttribute;
|
||||||
|
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||||
|
#else
|
||||||
|
using NUnit.Framework;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class QueryJsonIgnoreCase : TestFixtureBase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Example()
|
||||||
|
{
|
||||||
|
#region Usage
|
||||||
|
string json = @"{
|
||||||
|
'name': 'James Newton-King',
|
||||||
|
'blog': 'http://james.newtonking.com'
|
||||||
|
}";
|
||||||
|
|
||||||
|
JObject profile = JObject.Parse(json);
|
||||||
|
|
||||||
|
string name = (string)profile.GetValue("Name", StringComparison.OrdinalIgnoreCase);
|
||||||
|
Console.WriteLine(name);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
Assert.AreEqual("James Newton-King", name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,11 +53,12 @@ namespace Newtonsoft.Json
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the string containing the same characters as the specified range of characters in the given array.
|
/// Gets a string containing the same characters as the specified range of characters in the given array.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">The character array containing the name to find.</param>
|
/// <param name="key">The character array containing the name to find.</param>
|
||||||
/// <param name="start">The zero-based index into the array specifying the first character of the name.</param>
|
/// <param name="start">The zero-based index into the array specifying the first character of the name.</param>
|
||||||
/// <param name="length">The number of characters in the name.</param>
|
/// <param name="length">The number of characters in the name.</param>
|
||||||
|
/// <returns>A string containing the same characters as the specified range of characters in the given array.</returns>
|
||||||
public override string Get(char[] key, int start, int length)
|
public override string Get(char[] key, int start, int length)
|
||||||
{
|
{
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
@@ -96,6 +97,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">The string to add.</param>
|
/// <param name="key">The string to add.</param>
|
||||||
/// <remarks>This method is not thread-safe.</remarks>
|
/// <remarks>This method is not thread-safe.</remarks>
|
||||||
|
/// <returns>The resolved string.</returns>
|
||||||
public string Add(string key)
|
public string Add(string key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
if (key == null)
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
public abstract class JsonNameTable
|
public abstract class JsonNameTable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the string containing the same characters as the specified range of characters in the given array.
|
/// Gets a string containing the same characters as the specified range of characters in the given array.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">The character array containing the name to find.</param>
|
/// <param name="key">The character array containing the name to find.</param>
|
||||||
/// <param name="start">The zero-based index into the array specifying the first character of the name.</param>
|
/// <param name="start">The zero-based index into the array specifying the first character of the name.</param>
|
||||||
/// <param name="length">The number of characters in the name.</param>
|
/// <param name="length">The number of characters in the name.</param>
|
||||||
|
/// <returns>A string containing the same characters as the specified range of characters in the given array.</returns>
|
||||||
public abstract string Get(char[] key, int start, int length);
|
public abstract string Get(char[] key, int start, int length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user