-Examples!

This commit is contained in:
James Newton-King
2013-01-28 00:07:21 +13:00
parent fd7970a3c3
commit 70ace8d527
115 changed files with 1120 additions and 210 deletions
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="DeserializeFromBson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example deserializes BSON to an object.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Bson\DeserializeFromBson.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Bson\DeserializeFromBson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="DeserializeFromBsonCollection" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example sets <codeEntityReference>P:Newtonsoft.Json.Bson.BsonReader.ReadRootValueAsArray</codeEntityReference>
to <code>true</code> so the root BSON value is correctly read
as an array instead of an object and deserializes BSON to a collection.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Bson\DeserializeFromBsonCollection.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Bson\DeserializeFromBsonCollection.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="SerializeToBson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example serializes an object to BSON.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Bson\SerializeToBson.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Bson\SerializeToBson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+23 -29
View File
@@ -2,40 +2,34 @@
<topic id="Examples" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>Json.NET has the ability to conditionally serialize properties by placing a ShouldSerialize method on a class.
This funtionality is similar to the <externalLink>
<linkText>XmlSerializer ShouldSerialize feature</linkText>
<linkUri>http://msdn.microsoft.com/en-us/library/53b8022e.aspx</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>.</para>
<para>These are examples of Json.NET being used with JSON and .NET.</para>
</introduction>
<section>
<title>ShouldSerialize</title>
<title>Examples</title>
<content>
<para>To conditionally serialize a property add a boolean method with the same name as the property and then prefixed the method name
with ShouldSerialize. The result of the method determines whether the property is serialized. If the method returns true then the
property will be serialized, if it returns false and the property will be skipped.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="EmployeeShouldSerializeExample" title="Employee class with a ShouldSerialize method" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeClassTest" title="ShouldSerialize output" />
<list class="bullet">
<listItem>
<para><legacyBold>Serializing JSON</legacyBold> - Serializing and deserializing JSON, serializer settings and serialization attributes</para>
</listItem>
<listItem>
<para><legacyBold>LINQ to JSON</legacyBold> - Parsing, querying, modifying and writing JSON</para>
</listItem>
<listItem>
<para><legacyBold>JSON Schema</legacyBold> - Parsing schemas and validating JSON</para>
</listItem>
<listItem>
<para><legacyBold>Converting XML</legacyBold> - Converting JSON to XML and XML to JSON</para>
</listItem>
<listItem>
<para><legacyBold>BSON</legacyBold> - Serializing and deserializing BSON</para>
</listItem>
<listItem>
<para><legacyBold>Reading and Writing JSON</legacyBold> - Reading JSON with JsonTextReader, writing JSON with JsonTextWriter</para>
</listItem>
</list>
</content>
</section>
<section>
<title>IContractResolver</title>
<content>
<para>ShouldSerialize can also be set using an <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>.
Conditionally serializing a property using an IContractResolver is useful if you don't want to place a ShouldSerialize method on a class
or you didn't declare the class and are unable to.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeContractResolver" title="Conditional properties with IContractResolver" />
</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
<codeEntityReference>P:Newtonsoft.Json.Serialization.JsonProperty.ShouldSerialize</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ReadJsonWithJsonTextReader" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example reads JSON using the <codeEntityReference>T:Newtonsoft.Json.JsonTextReader</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Json\ReadJsonWithJsonTextReader.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="WriteJsonWithJsonTextWriter" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example writes JSON using the <codeEntityReference>T:Newtonsoft.Json.JsonTextWriter</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Json\WriteJsonWithJsonTextWriter.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="Clone" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example clones LINQ to JSON objects and all the cloned object's child values.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\Clone.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateJsonAnonymousObject" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates a <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
from an anonymous type.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonAnonymousObject.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonAnonymousObject.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateJsonCollectionInitializer" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
and <codeEntityReference>T:Newtonsoft.Json.Linq.JArray</codeEntityReference> instances using
the C# collection initializer syntax.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonCollectionInitializer.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateJsonDeclaratively" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
and <codeEntityReference>T:Newtonsoft.Json.Linq.JArray</codeEntityReference> instances declaratively
using LINQ.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonDeclaratively.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonDeclaratively.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateJsonDynamic" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
and <codeEntityReference>T:Newtonsoft.Json.Linq.JArray</codeEntityReference> instances using
the C# dynamic functionality.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonDynamic.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateJsonJTokenWriter" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
and <codeEntityReference>T:Newtonsoft.Json.Linq.JArray</codeEntityReference> instances using
a <codeEntityReference>T:Newtonsoft.Json.Linq.JTokenWriter</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonJTokenWriter.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateJsonManually" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
and <codeEntityReference>T:Newtonsoft.Json.Linq.JArray</codeEntityReference> instances one at a time
programatically.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateJsonManually.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateReader" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates a <codeEntityReference>T:Newtonsoft.Json.Linq.JTokenReader</codeEntityReference>
from a <codeEntityReference>T:Newtonsoft.Json.Linq.JToken</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateReader.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateWriter" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates a <codeEntityReference>T:Newtonsoft.Json.Linq.JTokenWriter</codeEntityReference>
from a <codeEntityReference>T:Newtonsoft.Json.Linq.JToken</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\CreateWriter.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="DeepEquals" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example compares <codeEntityReference>T:Newtonsoft.Json.Linq.JToken</codeEntityReference>
instances using <codeEntityReference>M:Newtonsoft.Json.Linq.JToken.DeepEquals</codeEntityReference>,
comparing the token and all child tokens.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\DeepEquals.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="DeserializeWithLinq" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example uses LINQ to JSON to manually convert JSON to a .NET type.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\DeserializeWithLinq.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\DeserializeWithLinq.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="FromObject" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example converts .NET values to LINQ to JSON using
<codeEntityReference>M:Newtonsoft.Json.Linq.JToken.FromObject(System.Object)</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\FromObject.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\FromObject.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JObjectProperties" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example gets an object's <codeEntityReference>T:Newtonsoft.Json.Linq.JProperty</codeEntityReference>
collection using <codeEntityReference>M:Newtonsoft.Json.Linq.JObject.Properties</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\JObjectProperties.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JValueCast" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example casts <codeEntityReference>T:Newtonsoft.Json.Linq.JValue</codeEntityReference>
instances to .NET values.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\JValueCast.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JValueValue" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example gets <codeEntityReference>T:Newtonsoft.Json.Linq.JValue</codeEntityReference>
internal values using <codeEntityReference>P:Newtonsoft.Json.Linq.JValue.Value</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\JValueValue.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ModifyJson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example loads JSON, modifies <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
and <codeEntityReference>T:Newtonsoft.Json.Linq.JArray</codeEntityReference>
instances and then writes the JSON back out again.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ModifyJson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ParseJsonAny" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example parses JSON using
<codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Parse</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ParseJsonAny.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ParseJsonArray" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example parses a JSON array using
<codeEntityReference>M:Newtonsoft.Json.Linq.JArray.Parse</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ParseJsonArray.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ParseJsonObject" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example parses a JSON object using
<codeEntityReference>M:Newtonsoft.Json.Linq.JObject.Parse</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ParseJsonObject.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="QueryJson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example loads JSON and then queries values from it using
<codeEntityReference>T:Newtonsoft.Json.Linq.JToken.Items(System.Object)</codeEntityReference> indexer
and then casts the returned tokens to .NET values.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\QueryJson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="QueryJsonDynamic" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example loads JSON and then queries values from it using
C# dynamic functionality.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\QueryJsonDynamic.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="QueryJsonLinq" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example loads JSON and then queries values from it using LINQ operators.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\QueryJsonLinq.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="QueryJsonSelectToken" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example loads JSON and then queries values from it using <codeEntityReference>T:Newtonsoft.Json.Linq.JToken.SelectToken(System.String)</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\QueryJsonSelectToken.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="QueryJsonSelectTokenWithLinq" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example loads JSON and then queries values from it using a combination of <codeEntityReference>T:Newtonsoft.Json.Linq.JToken.SelectToken(System.String)</codeEntityReference>
and LINQ operators.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\QueryJsonSelectTokenWithLinq.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ReadJTokenFromBson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example reads a <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
from BSON using <codeEntityReference>T:Newtonsoft.Json.Bson.BsonReader</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ReadJTokenFromBson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ReadJson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example reads JSON from a file into a <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ReadJson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="SerializeWithLinq" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example uses LINQ to JSON to manually convert a .NET type to JSON.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\SerializeWithLinq.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\SerializeWithLinq.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ToObjectComplex" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example converts LINQ to JSON objects to .NET types using
<codeEntityReference>T:Newtonsoft.Json.Linq.JToken.ToObject`1</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ToObjectComplex.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ToObjectGeneric" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example converts LINQ to JSON objects to .NET types using
<codeEntityReference>T:Newtonsoft.Json.Linq.JToken.ToObject`1</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ToObjectGeneric.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ToObjectType" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example converts LINQ to JSON objects to .NET types using
<codeEntityReference>M:Newtonsoft.Json.Linq.JToken.ToObject(System.Type)</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ToObjectType.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ToString" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example converts LINQ to JSON objects to JSON.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ToString.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ToStringJsonConverter" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example uses a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
to customize converting LINQ to JSON objects to JSON.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\ToStringJsonConverter.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="WriteJTokenToBson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example writes a <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
to BSON using <codeEntityReference>T:Newtonsoft.Json.Bson.BsonWriter</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\WriteJTokenToBson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="WriteToJsonFile" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example writes LINQ to JSON objects to a file.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Linq\WriteToJsonFile.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="CreateJsonSchemaManually" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates a <codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchema</codeEntityReference>
instance programmatically instead of loading a schema from JSON.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\CreateJsonSchemaManually.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JTokenIsValid" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example validates a <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
using the <codeEntityReference>M:Newtonsoft.Json.Schema.Extensions.IsValid(Newtonsoft.Json.Linq.JToken,Newtonsoft.Json.Schema.JsonSchema)</codeEntityReference>
extension method.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\JTokenIsValid.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JTokenIsValidWithMessages" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example validates a <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
using the <codeEntityReference>M:Newtonsoft.Json.Schema.Extensions.IsValid(Newtonsoft.Json.Linq.JToken,Newtonsoft.Json.Schema.JsonSchema)</codeEntityReference>
extension method and returns error messages.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\JTokenIsValidWithMessages.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JTokenValidateWithEvent" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example validates a <codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
using the <codeEntityReference>M:Newtonsoft.Json.Schema.Extensions.IsValid(Newtonsoft.Json.Linq.JToken,Newtonsoft.Json.Schema.JsonSchema)</codeEntityReference>
extension method and raises an event for each validation error.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\JTokenValidateWithEvent.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JsonSchemaParse" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example parses a <codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchema</codeEntityReference>
from JSON</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\JsonSchemaParse.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="JsonValidatingReaderAndSerializer" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example validates JSON when deserializing an object using
<codeEntityReference>T:Newtonsoft.Json.JsonValidatingReader</codeEntityReference>.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\JsonValidatingReaderAndSerializer.cs" region="Types" title="Types" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\JsonValidatingReaderAndSerializer.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="LoadJsonSchemaFromFile" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example loads a <codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchema</codeEntityReference>
from a file.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\LoadJsonSchemaFromFile.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="RefJsonSchemaResolver" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example uses a <codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchemaResolver</codeEntityReference>
to resolve schema references from different JSON documents.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\RefJsonSchemaResolver.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="SaveJsonSchemaToFile" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example saves a <codeEntityReference>T:Newtonsoft.Json.Schema.JsonSchema</codeEntityReference>
to a file.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Schema\SaveJsonSchemaToFile.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
-70
View File
@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="Serializer" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
interface provides a way to customize how the
JsonSerializer serializes and deserializes .NET objects to JSON without placing attributes on your classes.
</para>
<para>Anything that can be set on an object, collection, property, etc, using attributes or methods to control serialization
can also be set using an IContractResolver.</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline />, add an address attribute to identify it
and specify a title so that it can be jumped to with a hyperlink. -->
<section>
<title>DefaultContractResolver</title>
<content>
<!-- Uncomment this to create a sub-section outline
<autoOutline /> -->
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
is the default resolver used by the
serializer. It provides many avenues of extensibility in the form of
virtual methods that can be overriden.</para>
</content>
</section>
<section>
<title>CamelCasePropertyNamesContractResolver</title>
<content>
<!-- Uncomment this to create a sub-section outline
<autoOutline /> -->
<para><codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
inherits from DefaultContractResolver and simply overrides the JSON
property name to be written in <externalLink>
<linkText>camelcase</linkText>
<linkUri>http://en.wikipedia.org/wiki/CamelCase</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ContractResolver" title="ContractResolver" />
</content>
</section>
<section>
<title>Custom IContractResolver Examples</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterContractResolver" title="Use JsonConverter with IContractResolver" />
<para>This example sets a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> for a type
using an IContractResolver. Using a contract resolver here is useful because DateTime is not your own type and it is not possible to place a JsonConverterAttribute on it.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeContractResolver" title="Conditional properties with IContractResolver" />
<para>This example sets up <externalLink>
<linkText>conditional serialization for a property</linkText>
<linkUri>ConditionalProperties.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink> using an IContractResolver. This is useful if you want to conditionally serialize a property but don't want to add additional methods to your type.</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
@@ -2,7 +2,7 @@
<topic id="DeserializeCustomCreationConverter" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example creates a class that inherits from <codeEntityReference>T:Newtonsoft.Json.CustomCreationConverter`1</codeEntityReference>
<para>This example creates a class that inherits from <codeEntityReference>T:Newtonsoft.Json.Converters.CustomCreationConverter`1</codeEntityReference>
that instantiates Employee instances for the Person type.</para>
</introduction>
<section>
@@ -3,7 +3,7 @@
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.JsonObjectAttribute</codeEntityReference>
to serialize a class that implements <codeEntityReference>T:System.IEnumerable`1</codeEntityReference> as
to serialize a class that implements <codeEntityReference>T:System.Collections.IEnumerable`1</codeEntityReference> as
a JSON object instead of a JSON array.</para>
</introduction>
<section>
+1 -1
View File
@@ -2,7 +2,7 @@
<topic id="SerializeDataSet" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example serializes a DataSet to JSON.</para>
<para>This example serializes a <codeEntityReference>T:System.Data.DataSet</codeEntityReference> to JSON.</para>
</introduction>
<section>
<title>Example</title>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ConvertJsonToXml" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example converts JSON to XML.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Xml\ConvertJsonToXml.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ConvertXmlToJson" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example converts XML to JSON.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Xml\ConvertXmlToJson.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="ConvertXmlToJsonForceArray" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>This example reads the <code>json:Array=&quot;true&quot;</code> attribute in the XML and places its value in an array
when converting the XML to JSON.</para>
</introduction>
<section>
<title>Example</title>
<content>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Xml\ConvertXmlToJsonForceArray.cs" region="Usage" title="Usage" />
</content>
</section>
</developerConceptualDocument>
</topic>
+114 -53
View File
@@ -23,63 +23,124 @@
<Topic id="QueryingLINQtoJSON" visible="True" title="Querying JSON with LINQ" />
<Topic id="SelectToken" visible="True" title="Querying JSON with SelectToken" />
</Topic>
<Topic id="Performance" visible="True" title="Performance" />
<Topic id="JsonSchema" visible="True" title="Validating JSON" />
<Topic id="Performance" visible="True" title="Performance Tips" />
<Topic id="JsonSchema" visible="True" title="Validating JSON with JSON Schema" />
<Topic id="ReadingWritingJSON" visible="True" title="Basic Reading and Writing JSON" />
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
<Topic id="JsonNetVsDotNetSerializers" visible="True" title="Json.NET vs .NET Serializers" />
<Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" />
<Topic id="Examples" visible="True" isExpanded="true">
<Topic id="Serializer" visible="True" isExpanded="true">
<Topic id="CustomContractResolver" visible="True" title="Custom Contract Resolver" />
<Topic id="CustomJsonConverter" visible="True" />
<Topic id="CustomTraceWriter" visible="True" />
<Topic id="DataContractAndDataMember" visible="True" />
<Topic id="DefaultValueAttributeIgnore" visible="True" />
<Topic id="DefaultValueHandlingIgnore" visible="True" />
<Topic id="DeserializeAnonymousType" visible="True" />
<Topic id="DeserializeCollection" visible="True" />
<Topic id="DeserializeConstructorHandling" visible="True" />
<Topic id="DeserializeCustomCreationConverter" visible="True" />
<Topic id="DeserializeDataSet" visible="True" />
<Topic id="DeserializeDictionary" visible="True" />
<Topic id="DeserializeMissingMemberHandling" visible="True" />
<Topic id="DeserializeObject" visible="True" />
<Topic id="DeserializeObjectCreationHandling" visible="True" isSelected="true" />
<Topic id="DeserializeWithJsonSerializerFromFile" visible="True" />
<Topic id="ErrorHandlingAttribute" visible="True" />
<Topic id="ErrorHandlingEvent" visible="True" />
<Topic id="JsonConverterAttributeClass" visible="True" />
<Topic id="JsonConverterAttributeProperty" visible="True" />
<Topic id="JsonObjectAttributeOptIn" visible="True" />
<Topic id="JsonObjectAttributeOverrideIEnumerable" visible="True" />
<Topic id="JsonPropertyItemLevelSetting" visible="True" />
<Topic id="JsonPropertyName" visible="True" />
<Topic id="JsonPropertyOrder" visible="True" />
<Topic id="JsonPropertyPropertyLevelSetting" visible="True" />
<Topic id="JsonPropertyRequired" visible="True" />
<Topic id="MaxDepth" visible="True" />
<Topic id="NullValueHandlingIgnore" visible="True" />
<Topic id="PopulateObject" visible="True" />
<Topic id="PreserveReferencesHandlingObject" visible="True" />
<Topic id="PropertyJsonIgnore" visible="True" />
<Topic id="ReferenceLoopHandlingIgnore" visible="True" />
<Topic id="SerializationCallbackAttributes" visible="True" />
<Topic id="SerializeCollection" visible="True" />
<Topic id="SerializeConditionalProperty" visible="True" />
<Topic id="SerializeContractResolver" visible="True" />
<Topic id="SerializeDataSet" visible="True" />
<Topic id="SerializeDateFormatHandling" visible="True" />
<Topic id="SerializeDateTimeZoneHandling" visible="True" />
<Topic id="SerializeDictionary" visible="True" />
<Topic id="SerializeObject" visible="True" />
<Topic id="SerializeRawJson" visible="True" />
<Topic id="SerializeSerializationBinder" visible="True" />
<Topic id="SerializeTypeNameHandling" visible="True" />
<Topic id="SerializeUnindentedJson" visible="True" />
<Topic id="SerializeWithJsonConverters" visible="True" />
<Topic id="SerializeWithJsonSerializerToFile" visible="True" />
<Topic id="TraceWriter" visible="True" />
<Topic id="Examples" visible="True" isExpanded="true" title="Examples">
<Topic id="d6e185d5-c992-44fc-8d8f-d9acc2bbec2f" visible="True" noFile="true" isExpanded="true" title="Serializing JSON">
<Topic id="SerializeObject" visible="True" title="Serialize an Object" />
<Topic id="SerializeCollection" visible="True" title="Serialize a Collection" />
<Topic id="SerializeDictionary" visible="True" title="Serialize a Dictionary" />
<Topic id="SerializeWithJsonSerializerToFile" visible="True" title="Serialize JSON to a file" />
<Topic id="SerializeWithJsonConverters" visible="True" title="Serialize with JsonConverters" />
<Topic id="SerializeDataSet" visible="True" title="Serialize a DataSet" />
<Topic id="SerializeRawJson" visible="True" title="Serialize Raw JSON value" />
<Topic id="SerializeUnindentedJson" visible="True" title="Serialize Unindented JSON" />
<Topic id="SerializeConditionalProperty" visible="True" title="Serialize Conditional Property" />
<Topic id="DeserializeObject" visible="True" title="Deserialize an Object" />
<Topic id="DeserializeCollection" visible="True" title="Deserialize a Collection" />
<Topic id="DeserializeDictionary" visible="True" title="Deserialize a Dictionary" />
<Topic id="DeserializeAnonymousType" visible="True" title="Deserialize an Anonymous Type" />
<Topic id="DeserializeDataSet" visible="True" title="Deserialize a DataSet" />
<Topic id="DeserializeCustomCreationConverter" visible="True" title="Deserialize with CustomCreationConverter" />
<Topic id="DeserializeWithJsonSerializerFromFile" visible="True" title="Deserialize JSON from a file" />
<Topic id="PopulateObject" visible="True" title="Populate an Object" />
<Topic id="DeserializeConstructorHandling" visible="True" title="ConstructorHandling setting" />
<Topic id="DeserializeObjectCreationHandling" visible="True" title="ObjectCreationHandling setting" />
<Topic id="DefaultValueHandlingIgnore" visible="True" title="DefaultValueHandling setting" />
<Topic id="DeserializeMissingMemberHandling" visible="True" title="MissingMemberHandling setting" />
<Topic id="NullValueHandlingIgnore" visible="True" title="NullValueHandling setting" />
<Topic id="ReferenceLoopHandlingIgnore" visible="True" title="RefereneLoopHandling setting" />
<Topic id="PreserveReferencesHandlingObject" visible="True" title="PreserveReferencesHandling setting" />
<Topic id="SerializeDateFormatHandling" visible="True" title="DateFormatHandling setting" />
<Topic id="SerializeDateTimeZoneHandling" visible="True" title="DateTimeZoneHandling setting" />
<Topic id="SerializeTypeNameHandling" visible="True" title="TypeNameHandling setting" />
<Topic id="SerializeContractResolver" visible="True" title="ContractResolver setting" />
<Topic id="TraceWriter" visible="True" title="TraceWriter setting" />
<Topic id="ErrorHandlingEvent" visible="True" title="ErrorHandling setting" />
<Topic id="MaxDepth" visible="True" title="MaxDepth setting" />
<Topic id="CustomJsonConverter" visible="True" title="Custom JsonConverter" />
<Topic id="CustomContractResolver" visible="True" title="Custom IContractResolver" />
<Topic id="CustomTraceWriter" visible="True" title="Custom ITraceWriter" />
<Topic id="SerializeSerializationBinder" visible="True" title="Custom SerializationBinder" />
<Topic id="JsonConverterAttributeClass" visible="True" title="JsonConverterAttribute on a class" />
<Topic id="JsonConverterAttributeProperty" visible="True" title="JsonConverterAttribute on a property" />
<Topic id="JsonObjectAttributeOptIn" visible="True" title="JsonObjectAttribute opt-in serialization" />
<Topic id="JsonObjectAttributeOverrideIEnumerable" visible="True" title="JsonObjectAttribute force object serialization" />
<Topic id="JsonPropertyName" visible="True" title="JsonPropertyAttribute name" />
<Topic id="JsonPropertyOrder" visible="True" title="JsonPropertyAttribute order" />
<Topic id="JsonPropertyRequired" visible="True" title="JsonPropertyAttribute required" />
<Topic id="JsonPropertyItemLevelSetting" visible="True" title="JsonPropertyAttribute items setting" />
<Topic id="JsonPropertyPropertyLevelSetting" visible="True" title="JsonPropertyAttribute property setting" />
<Topic id="PropertyJsonIgnore" visible="True" title="JsonIgnoreAttribute" />
<Topic id="ErrorHandlingAttribute" visible="True" title="ErrorHandlingAttribute" />
<Topic id="DefaultValueAttributeIgnore" visible="True" isSelected="true" title="DefaultValueAttribute" />
<Topic id="SerializationCallbackAttributes" visible="True" title="Serialization Callback Attributes" />
<Topic id="DataContractAndDataMember" visible="True" title="DataContract and DataMember Attributes" />
</Topic>
<Topic id="68b9fad2-5436-4e35-a734-9b9d751cc3e5" visible="True" noFile="true" title="LINQ to JSON">
<Topic id="CreateJsonManually" visible="True" title="Create JSON manually" />
<Topic id="CreateJsonAnonymousObject" visible="True" title="Create JSON from an Anonymous Object" />
<Topic id="CreateJsonCollectionInitializer" visible="True" title="Create JSON using Collection Initializers" />
<Topic id="CreateJsonDeclaratively" visible="True" title="Create JSON declaratively with LINQ" />
<Topic id="CreateJsonDynamic" visible="True" title="Create JSON with dynamic" />
<Topic id="CreateJsonJTokenWriter" visible="True" title="Create JSON with JTokenWriter" />
<Topic id="FromObject" visible="True" title="Create JSON from an Object" />
<Topic id="ParseJsonArray" visible="True" title="Parsing JSON Array using JArray.Parse" />
<Topic id="ParseJsonObject" visible="True" title="Parsing JSON Object using JObject.Parse" />
<Topic id="ParseJsonAny" visible="True" title="Parsing all JSON using JToken.Parse" />
<Topic id="DeserializeWithLinq" visible="True" title="Deserializing from JSON with LINQ" />
<Topic id="SerializeWithLinq" visible="True" title="Serializing to JSON with LINQ" />
<Topic id="ModifyJson" visible="True" title="Modifying JSON" />
<Topic id="QueryJson" visible="True" title="Querying JSON" />
<Topic id="QueryJsonDynamic" visible="True" title="Querying JSON with dynamic" />
<Topic id="QueryJsonLinq" visible="True" title="Querying JSON with LINQ" />
<Topic id="QueryJsonSelectToken" visible="True" title="Querying JSON with SelectToken" />
<Topic id="QueryJsonSelectTokenWithLinq" visible="True" title="Querying JSON with SelectToken and LINQ" />
<Topic id="ReadJson" visible="True" title="Read JSON from 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="ToObjectGeneric" visible="True" title="Convert JSON to Value" />
<Topic id="ToObjectType" visible="True" title="Convert JSON to a Type" />
<Topic id="JValueCast" visible="True" title="Casting JValue" />
<Topic id="JValueValue" visible="True" title="Using JValue.Value" />
<Topic id="JObjectProperties" visible="True" title="Using JObject.Properties" />
<Topic id="DeepEquals" visible="True" title="Comparing JSON with JToken.DeepEquals" />
<Topic id="Clone" visible="True" title="Cloning JSON with JToken.DeepClone" />
<Topic id="ToString" visible="True" title="Write JSON text with JToken.ToString" />
<Topic id="ToStringJsonConverter" visible="True" title="Using JToken.ToString with JsonConverter" />
<Topic id="CreateReader" visible="True" title="Using JToken.CreateReader" />
<Topic id="CreateWriter" visible="True" title="Using JToken.CreateWriter" />
<Topic id="ReadJTokenFromBson" visible="True" title="Read from BSON" />
<Topic id="WriteJTokenToBson" visible="True" title="Write as BSON" />
</Topic>
<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="LoadJsonSchemaFromFile" visible="True" title="Load JSON Schema from a file" />
<Topic id="CreateJsonSchemaManually" visible="True" title="Create JSON Schema manually" />
<Topic id="SaveJsonSchemaToFile" visible="True" title="Save JSON Schema to a file" />
<Topic id="JTokenIsValid" visible="True" title="Validate JSON with JToken.IsValid" />
<Topic id="JTokenIsValidWithMessages" visible="True" title="Validate with validation error messages" />
<Topic id="JTokenValidateWithEvent" visible="True" title="Validate with validation error events" />
<Topic id="JsonValidatingReaderAndSerializer" visible="True" title="Validate JSON with JsonValidatingReader" />
<Topic id="RefJsonSchemaResolver" visible="True" title="Using JsonSchemaResolver" />
</Topic>
<Topic id="0eeb9041-1824-48aa-b070-50d5fcd6ab68" visible="True" noFile="true" title="Converting XML">
<Topic id="ConvertJsonToXml" visible="True" title="Convert JSON to XML" />
<Topic id="ConvertXmlToJson" visible="True" title="Convert XML to JSON" />
<Topic id="ConvertXmlToJsonForceArray" visible="True" title="Convert XML to JSON and force array" />
</Topic>
<Topic id="d3ec6e07-1411-4fde-ba66-c0cede5e1ae8" visible="True" noFile="true" title="BSON">
<Topic id="SerializeToBson" visible="True" title="Serialize to BSON" />
<Topic id="DeserializeFromBson" visible="True" title="Deserialize from BSON" />
<Topic id="DeserializeFromBsonCollection" visible="True" title="Deserialize a Collection from BSON" />
</Topic>
<Topic id="ca145ed0-f377-4f1c-9479-d1629082fc6e" visible="True" noFile="true" title="Reading and Writing JSON">
<Topic id="ReadJsonWithJsonTextReader" visible="True" title="Read JSON with JsonTextReader" />
<Topic id="WriteJsonWithJsonTextWriter" visible="True" title="Write JSON with JsonTextWriter" />
</Topic>
</Topic>
</Topics>
+56
View File
@@ -137,6 +137,57 @@
<Content Include="donate.gif" />
</ItemGroup>
<ItemGroup>
<None Include="Examples\Xml\ConvertXmlToJsonForceArray.aml" />
<None Include="Examples\Xml\ConvertXmlToJson.aml" />
<None Include="Examples\Xml\ConvertJsonToXml.aml" />
<None Include="Examples\Schema\SaveJsonSchemaToFile.aml" />
<None Include="Examples\Schema\RefJsonSchemaResolver.aml" />
<None Include="Examples\Schema\LoadJsonSchemaFromFile.aml" />
<None Include="Examples\Schema\JTokenValidateWithEvent.aml" />
<None Include="Examples\Schema\JTokenIsValidWithMessages.aml" />
<None Include="Examples\Schema\JTokenIsValid.aml" />
<None Include="Examples\Schema\JsonValidatingReaderAndSerializer.aml" />
<None Include="Examples\Schema\JsonSchemaParse.aml" />
<None Include="Examples\Schema\CreateJsonSchemaManually.aml" />
<None Include="Examples\Linq\WriteToJsonFile.aml" />
<None Include="Examples\Linq\WriteJTokenToBson.aml" />
<None Include="Examples\Linq\ToStringJsonConverter.aml" />
<None Include="Examples\Linq\ToString.aml" />
<None Include="Examples\Linq\ToObjectType.aml" />
<None Include="Examples\Linq\ToObjectGeneric.aml" />
<None Include="Examples\Linq\ToObjectComplex.aml" />
<None Include="Examples\Linq\SerializeWithLinq.aml" />
<None Include="Examples\Linq\ReadJTokenFromBson.aml" />
<None Include="Examples\Linq\ReadJson.aml" />
<None Include="Examples\Linq\QueryJsonSelectTokenWithLinq.aml" />
<None Include="Examples\Linq\QueryJsonSelectToken.aml" />
<None Include="Examples\Linq\QueryJsonLinq.aml" />
<None Include="Examples\Linq\QueryJsonDynamic.aml" />
<None Include="Examples\Linq\QueryJson.aml" />
<None Include="Examples\Linq\ParseJsonObject.aml" />
<None Include="Examples\Linq\ParseJsonArray.aml" />
<None Include="Examples\Linq\ParseJsonAny.aml" />
<None Include="Examples\Linq\ModifyJson.aml" />
<None Include="Examples\Linq\JValueValue.aml" />
<None Include="Examples\Linq\JValueCast.aml" />
<None Include="Examples\Linq\JObjectProperties.aml" />
<None Include="Examples\Linq\FromObject.aml" />
<None Include="Examples\Linq\DeserializeWithLinq.aml" />
<None Include="Examples\Linq\DeepEquals.aml" />
<None Include="Examples\Linq\CreateWriter.aml" />
<None Include="Examples\Linq\CreateReader.aml" />
<None Include="Examples\Linq\CreateJsonManually.aml" />
<None Include="Examples\Linq\CreateJsonJTokenWriter.aml" />
<None Include="Examples\Linq\CreateJsonDynamic.aml" />
<None Include="Examples\Linq\CreateJsonDeclaratively.aml" />
<None Include="Examples\Linq\CreateJsonCollectionInitializer.aml" />
<None Include="Examples\Linq\CreateJsonAnonymousObject.aml" />
<None Include="Examples\Linq\Clone.aml" />
<None Include="Examples\Json\WriteJsonWithJsonTextWriter.aml" />
<None Include="Examples\Json\ReadJsonWithJsonTextReader.aml" />
<None Include="Examples\Bson\SerializeToBson.aml" />
<None Include="Examples\Bson\DeserializeFromBsonCollection.aml" />
<None Include="Examples\Bson\DeserializeFromBson.aml" />
<None Include="Examples\Serializer\TraceWriter.aml" />
<None Include="Examples\Serializer\SerializeWithJsonSerializerToFile.aml" />
<None Include="Examples\Serializer\SerializeWithJsonConverters.aml" />
@@ -243,6 +294,11 @@
</Image>
</ItemGroup>
<ItemGroup>
<Folder Include="Examples\Xml\" />
<Folder Include="Examples\Schema\" />
<Folder Include="Examples\Linq\" />
<Folder Include="Examples\Json\" />
<Folder Include="Examples\Bson\" />
<Folder Include="Examples\Serializer\" />
<Folder Include="Examples\" />
</ItemGroup>
@@ -9,14 +9,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Bson
{
public class DeserializeFromBson
{
#region Types
public class Event
{
public string Name { get; set; }
public DateTime StartDate { get; set; }
}
#endregion
public void Example()
{
#region Usage
byte[] data = Convert.FromBase64String("MQAAAAJOYW1lAA8AAABNb3ZpZSBQcmVtaWVyZQAJU3RhcnREYXRlAMDgKWE8AQAAAA==");
MemoryStream ms = new MemoryStream(data);
@@ -29,6 +32,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Bson
Console.WriteLine(e.Name);
// Movie Premiere
}
#endregion
}
}
}
@@ -9,14 +9,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Bson
{
public class DeserializeFromBsonCollection
{
#region Types
public class Event
{
public string Name { get; set; }
public DateTime StartDate { get; set; }
}
#endregion
public void Example()
{
#region Usage
byte[] data = Convert.FromBase64String("awAAAAMwADAAAAACTmFtZQAOAAAATW92aWUgcHJlbWllcgAJU3RhcnREYXRlAMDgKWE8AQAAAAMxADAAAAACTmFtZQAOAAAATW92aWUgcHJlbWllcgAJU3RhcnREYXRlAMDgKWE8AQAAAAA=");
MemoryStream ms = new MemoryStream(data);
@@ -31,6 +34,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Bson
Console.WriteLine(events.Count);
// 2
}
#endregion
}
}
}
@@ -10,14 +10,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Bson
{
public class SerializeToBson
{
#region Types
public class Event
{
public string Name { get; set; }
public DateTime StartDate { get; set; }
}
#endregion
public void Example()
{
#region Usage
Event e = new Event
{
Name = "Movie Premiere",
@@ -35,6 +38,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Bson
Console.WriteLine(data);
// MQAAAAJOYW1lAA8AAABNb3ZpZSBQcmVtaWVyZQAJU3RhcnREYXRlAMDgKWE8AQAAAA==
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Json
{
public void Example()
{
#region Usage
string json = @"{
'CPU': 'Intel',
'PSU': '500W',
@@ -43,6 +44,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Json
// Token: String, Value: 200 gigabype hard drive
// Token: EndArray
// Token: EndObject
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Json
{
public void Example()
{
#region Usage
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
@@ -43,6 +44,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Json
// "200 gigabype hard drive"
// ]
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o1 = new JObject
{
{"String", "A string!"},
@@ -41,6 +42,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(Object.ReferenceEquals(o1, o2));
// false
#endregion
}
}
}
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public class CreateJsonAnonymousObject
{
#region Types
public class Post
{
public string Title { get; set; }
@@ -15,9 +16,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
public string Link { get; set; }
public IList<string> Categories { get; set; }
}
#endregion
public void Example()
{
#region Usage
List<Post> posts = new List<Post>
{
new Post
@@ -72,6 +75,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// ]
// }
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = new JObject
{
{"Cpu", "Intel"},
@@ -32,6 +33,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// "SSD"
// ]
// }
#endregion
}
}
}
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public class CreateJsonDeclaratively
{
#region Types
public class Post
{
public string Title { get; set; }
@@ -15,13 +16,16 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
public string Link { get; set; }
public IList<string> Categories { get; set; }
}
#endregion
private List<Post> GetPosts()
{
return null;
}
public void Example()
{
#region Usage
List<Post> posts = GetPosts();
JObject rss =
@@ -73,6 +77,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// ]
// }
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
dynamic product = new JObject();
product.ProductName = "Elbow Grease";
product.Enabled = true;
@@ -30,6 +31,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// "OnSale"
// ]
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JTokenWriter writer = new JTokenWriter();
writer.WriteStartObject();
writer.WritePropertyName("name1");
@@ -31,6 +32,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// 2
// ]
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JArray array = new JArray();
JValue text = new JValue("Manual text");
JValue date = new JValue(new DateTime(2000, 5, 23));
@@ -17,13 +18,19 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
array.Add(text);
array.Add(date);
string json = array.ToString();
JObject o = new JObject();
o["MyArray"] = array;
string json = o.ToString();
Console.WriteLine(json);
// [
// "Manual text",
// "2000-05-23T00:00:00"
// ]
// {
// "MyArray": [
// "Manual text",
// "2000-05-23T00:00:00"
// ]
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = new JObject
{
{"Cpu", "Intel"},
@@ -44,6 +45,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// String - SSD
// EndArray
// EndObject
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = new JObject
{
{"name1", "value1"},
@@ -32,6 +33,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// 2
// ]
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JValue s1 = new JValue("A string");
JValue s2 = new JValue("A string");
JValue s3 = new JValue("A STRING");
@@ -39,6 +40,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(JToken.DeepEquals(s1, o1["String"]));
// true
#endregion
}
}
}
@@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public class DeserializeWithLinq
{
#region Types
public class BlogPost
{
public string Title { get; set; }
@@ -17,9 +18,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
public string Body { get; set; }
public DateTime PostedDate { get; set; }
}
#endregion
public void Example()
{
#region Usage
string json = @"[
{
'Title': 'Json.NET is awesome!',
@@ -47,6 +50,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(blogPosts[0].Body);
// <h3>Title!</h3>
// <p>Content!</p>
#endregion
}
}
}
@@ -8,15 +8,18 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public class FromObject
{
#region Types
public class Computer
{
public string Cpu { get; set; }
public int Memory { get; set; }
public IList<string> Drives { get; set; }
}
#endregion
public void Example()
{
#region Usage
JValue i = (JValue)JToken.FromObject(12345);
Console.WriteLine(i.Type);
@@ -61,6 +64,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// "DVD",
// "SSD"
// ]
#endregion
}
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = new JObject
{
{ "name1", "value1" },
@@ -29,6 +30,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
}
// name1 - value1
// name2 - value2
#endregion
}
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JValue v1 = new JValue("1");
int i = (int)v1;
@@ -50,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine((dt != null) ? dt.ToString() : "{null}");
// {null}
#endregion
}
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JValue s = new JValue("A string value");
Console.WriteLine(s.Value.GetType().Name);
@@ -23,6 +24,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// Uri
Console.WriteLine(u.Value);
// http://www.google.com/
#endregion
}
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
string json = @"{
'channel': {
'title': 'Star Wars',
@@ -48,6 +49,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// ]
// }
// }
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JToken t1 = JToken.Parse("{}");
Console.WriteLine(t1.Type);
@@ -29,6 +30,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(t4.Type);
// String
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
string json = @"[
'Small',
'Medium',
@@ -24,6 +25,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// "Medium",
// "Large"
// ]
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
string json = @"{
CPU: 'Intel',
Drives: [
@@ -28,6 +29,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// "500 gigabyte hard drive"
// ]
// }
#endregion
}
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
string json = @"{
'channel': {
'title': 'James Newton-King',
@@ -62,6 +63,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(string.Join(", ", categoriesText));
// Json.NET, CodePlex
#endregion
}
}
}
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
string json = @"[
{
'Title': 'Json.NET is awesome!',
@@ -29,16 +30,20 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
dynamic blogPost = blogPosts[0];
string title = blogPost.Title;
Console.WriteLine(title);
// Json.NET is awesome!
string author = blogPost.Author.Name;
Console.WriteLine(author);
// James Newton-King
DateTime postDate = blogPost.Date;
Console.WriteLine(postDate);
// 23/01/2013 7:30:00 p.m.
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
string json = @"{
'channel': {
'title': 'James Newton-King',
@@ -48,7 +49,6 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
Console.WriteLine(item);
}
//LINQ to JSON beta
//Json.NET 1.3 + New license + Now on CodePlex
@@ -62,10 +62,10 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
Console.WriteLine(c.Category + " - Count: " + c.Count);
}
//Json.NET - Count: 2
//LINQ - Count: 1
//CodePlex - Count: 1
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = JObject.Parse(@"{
'Stores': [
'Lambton Quay',
@@ -55,6 +56,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(productName);
// Elbow Grease
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = JObject.Parse(@"{
'Stores': [
'Lambton Quay',
@@ -55,6 +56,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(totalPrice);
// 149.95
#endregion
}
}
}
}
@@ -12,6 +12,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
byte[] data = Convert.FromBase64String("KQAAAAJuYW1lMQAHAAAAdmFsdWUxAAJuYW1lMgAHAAAAdmFsdWUyAAA=");
MemoryStream ms = new MemoryStream(data);
@@ -25,6 +26,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(value);
// value1
#endregion
}
}
}
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o1 = JObject.Parse(File.ReadAllText(@"c:\videogames.json"));
// read JSON directly from a file
@@ -19,6 +20,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
JObject o2 = (JObject) JToken.ReadFrom(reader);
}
#endregion
}
}
}
@@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public class SerializeWithLinq
{
#region Types
public class BlogPost
{
public string Title { get; set; }
@@ -17,9 +18,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
public string Body { get; set; }
public DateTime PostedDate { get; set; }
}
#endregion
public void Example()
{
#region Usage
IList<BlogPost> blogPosts = new List<BlogPost>
{
new BlogPost
@@ -29,7 +32,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
AuthorTwitter = "JamesNK",
PostedDate = new DateTime(2013, 1, 23, 19, 30, 0),
Body = @"<h3>Title!</h3>
<p>Content!</p>"
<p>Content!</p>"
}
};
@@ -61,6 +64,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
// "BodyHtml": "&lt;h3&gt;Title!&lt;/h3&gt;\r\n&lt;p&gt;Content!&lt;/p&gt;"
// }
// ]
#endregion
}
}
}
}
@@ -8,13 +8,16 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public class ToObjectComplex
{
#region Types
public class Person
{
public string Name { get; set; }
}
#endregion
public void Example()
{
#region Usage
string json = @"{
'd': [
{
@@ -37,6 +40,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(person[1].Name);
// Mike Smith
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JValue v1 = new JValue(true);
bool b = v1.ToObject<bool>();
@@ -26,6 +27,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(s);
// "True"
#endregion
}
}
}
@@ -10,6 +10,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JValue v1 = new JValue(true);
bool b = (bool)v1.ToObject(typeof(bool));
@@ -26,6 +27,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(s);
// "True"
#endregion
}
}
}
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = JObject.Parse(@"{'string1':'value','integer2':99,'datetime3':'2000-05-23T00:00:00'}");
Console.WriteLine(o.ToString());
@@ -25,6 +26,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(o.ToString(Formatting.None, new JavaScriptDateTimeConverter()));
// {"string1":"value","integer2":99,"datetime3":new Date(959032800000)}
#endregion
}
}
}
@@ -11,10 +11,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = JObject.Parse(@"{'string1':'value','integer2':99,'datetime3':'2000-05-23T00:00:00'}");
Console.WriteLine(o.ToString(Formatting.None, new JavaScriptDateTimeConverter()));
// {"string1":"value","integer2":99,"datetime3":new Date(959032800000)}
#endregion
}
}
}
@@ -12,6 +12,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject o = new JObject
{
{"name1","value1"},
@@ -28,6 +29,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
Console.WriteLine(data);
// KQAAAAJuYW1lMQAHAAAAdmFsdWUxAAJuYW1lMgAHAAAAdmFsdWUyAAA=
#endregion
}
}
}
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public void Example()
{
#region Usage
JObject videogameRatings = new JObject(
new JProperty("Halo", 9),
new JProperty("Starcraft", 9),
@@ -24,6 +25,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
videogameRatings.WriteTo(writer);
}
#endregion
}
}
}
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema
{
public void Example()
{
#region Usage
JsonSchema schema = new JsonSchema();
schema.Type = JsonSchemaType.Object;
schema.Properties = new Dictionary<string, JsonSchema>
@@ -52,6 +53,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema
Console.WriteLine(valid);
// true
#endregion
}
}
}
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema
{
public void Example()
{
#region Usage
string schemaJson = @"{
'description': 'A person',
'type': 'object',
@@ -34,6 +35,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema
Console.WriteLine(valid);
// true
#endregion
}
}
}
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema
{
public void Example()
{
#region Usage
string schemaJson = @"{
'description': 'A person',
'type': 'object',
@@ -42,6 +43,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema
}
// Invalid type. Expected String but got Null. Line 2, position 21.
// Invalid type. Expected String but got Float. Line 3, position 51.
#endregion
}
}
}

Some files were not shown because too many files have changed in this diff Show More