~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/Newtonsoft.Json/Doc/QueryingLINQtoJSON.aml

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?>
 
2
<topic id="QueryingLINQtoJSON" revisionNumber="1">
 
3
  <developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
 
4
    <introduction>
 
5
      <para>LINQ to JSON provides a number of methods for getting data from its objects. The index methods on JObject/JArray let you quickly get data by its property name
 
6
      on an object or index in a collection, while <codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Children</codeEntityReference> lets you get ranges
 
7
      of data as <codeInline>IEnumerable&lt;JToken&gt;</codeInline> to then query using LINQ.</para>
 
8
    </introduction>
 
9
    
 
10
    <section>
 
11
      <title>Getting values by Property Name or Collection Index</title>
 
12
      <content>
 
13
        <!-- Uncomment this to create a sub-section outline
 
14
        <autoOutline /> -->
 
15
        <para>The simplest way to get a value from LINQ to JSON is to use the
 
16
        <codeEntityReference>P:Newtonsoft.Json.Linq.JToken.Item(System.Object)</codeEntityReference> index on
 
17
        JObject/JArray and then cast the returned <codeEntityReference>T:Newtonsoft.Json.Linq.JValue</codeEntityReference> to the type you want.
 
18
        </para>
 
19
 
 
20
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonSimpleQuerying" title="Getting JSON Values" />
 
21
 
 
22
      </content>
 
23
    </section>
 
24
    <section>
 
25
      <title>Querying with LINQ</title>
 
26
      <content>
 
27
        <para>JObject/JArray can also be queried using LINQ. <codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Children</codeEntityReference>
 
28
        returns the children values of a JObject/JArray
 
29
                as an <codeInline>IEnumerable&lt;JToken&gt;</codeInline> that can then be queried with the standard Where/OrderBy/Select LINQ operators.</para>
 
30
        
 
31
<alert class="note">
 
32
        <para><codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Children</codeEntityReference> returns all the children of a token. If it is a
 
33
        JObject it will return a collection of properties to work with and if
 
34
        it is a JArray you will get a collection of the array's values.</para>
 
35
</alert>
 
36
 
 
37
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonQuerying" title="Querying JSON" />
 
38
 
 
39
        <para>LINQ to JSON can also be used to manually convert JSON to a .NET object.</para>
 
40
 
 
41
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonDeserializeObject" title="Deserializing Using LINQ Objects" />
 
42
 
 
43
        <para>Manually serializing and deserializing between .NET objects is useful when you are
 
44
        working with JSON that doesn't closely match your .NET objects.</para>
 
45
 
 
46
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonDeserializeExample" title="Deserializing Using LINQ Example" />
 
47
      </content>
 
48
    </section>
 
49
    <relatedTopics>
 
50
      <externalLink>
 
51
        <linkText>LINQ to JSON</linkText>
 
52
        <linkUri>LINQtoJSON.htm</linkUri>
 
53
        <linkTarget>_self</linkTarget>
 
54
      </externalLink>
 
55
 
 
56
      <codeEntityReference>P:Newtonsoft.Json.Linq.JToken.Item(System.Object)</codeEntityReference>
 
57
      <codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Children</codeEntityReference>
 
58
    </relatedTopics>
 
59
  </developerConceptualDocument>
 
60
</topic>
 
 
b'\\ No newline at end of file'