<?xml version="1.0" encoding="utf-8"?>
<topic id="SelectToken" revisionNumber="1">
  <developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
    <introduction>
      <para>
      <codeEntityReference>Overload:Newtonsoft.Json.Linq.JToken.SelectToken</codeEntityReference>
      provides a method to query LINQ to JSON using a single string path to a desired
      <codeEntityReference>T:Newtonsoft.Json.Linq.JToken</codeEntityReference>.
      SelectToken makes dynamic queries easy because the entire query is defined in a string.</para>
    </introduction>
    <section>
      <title>SelectToken</title>
      <content>
        <!-- Uncomment this to create a sub-section outline
        <autoOutline /> -->
        <para>SelectToken is a method on JToken and takes a string path to a child token.
        SelectToken returns the child token or a null reference if a token couldn't be
        found at the path's location.</para>
        <para>The path is made up of property names and array indexes separated by periods.
        Array indexes can use either square or round brackets. Both of the following are
        valid paths and are equivalent to each other: <codeInline>Manufacturers[0].Name</codeInline>
        and <codeInline>Manufacturers(0).Name</codeInline>.</para>

<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="SelectTokenComplex" title="SelectToken Example" />
      </content>
    </section>
    <section>
      <title>SelectToken with LINQ</title>
      <content>
        <!-- Uncomment this to create a sub-section outline
        <autoOutline /> -->
        <para>SelectToken can be used in combination with standard LINQ methods.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="SelectTokenLinq" title="SelectToken With LINQ Example" />
      </content>
    </section>
    <relatedTopics>
      <externalLink>
        <linkText>LINQ to JSON</linkText>
        <linkUri>LINQtoJSON.htm</linkUri>
        <linkTarget>_self</linkTarget>
      </externalLink>

      <codeEntityReference>Overload:Newtonsoft.Json.Linq.JToken.SelectToken</codeEntityReference>
    </relatedTopics>
  </developerConceptualDocument>
</topic>