<?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>
      <autoOutline lead="none" excludeRelatedTopics="true" />
    </introduction>
    <section address="SelectToken">
      <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,
        e.g. <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 address="SelectTokenJSONPath">
      <title>SelectToken with JSONPath</title>
      <content>
        <para>SelectToken supports JSONPath queries. Find out more about JSONPath <externalLink>
<linkText>here</linkText>
<linkUri>https://goessner.net/articles/JsonPath/</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>.</para>

        <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Samples\JsonPath\QueryJsonSelectTokenJsonPath.cs" region="Usage" title="SelectToken With JSONPath" />
      </content>
    </section>
    <section address="SelectTokenLINQ">
      <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>
      <link xlink:href="LINQtoJSON" />

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