title: How to extract JSON serialization from HTML? C#
body: <p>First. My apology for being a JSON newbie. I suppose my ignorance makes it difficult for me to ask an accurate question. No worries, I will edit and clean up this post after clarity is reached.</p>
  
  <p>I have some html from a 3rd party website that has JSON data that I would like to extract. I've written unit tests that serialize/deserialize the JSON data to C# class. However, my offline test input file is generated by a manual copy paste operation: I opened the *.html source, found the JSON serialization data string, and copy pasted to an offline file. I then used it as input to my unit test. It works great.</p>
  
  <p>This manual copy/paste operation I'd like to make automatic. </p>
  
  <p>Currently the URL that I am using returns HTML - and the JSON data is buried in the <code>HtmlDocument</code> somewhere - and I haven't the foggiest how to determine what the direct JSON query url might be, or how to discover it. It would be ideal to know how to obtain this.</p>
  
  <p>With this background information explained I'll now ask my question(s).</p>
  
  <p>Conceptually I think there might be two questions to ask. There should be only one, but there in lies my ignorance: I'm not certain which question is the better to ask, or if the two I post below are even in the ballpark. My hope is that you understand what I'm asking from a conceptual view point and after I reach some understanding I can modify it to a more technical/accurate viewpoint. Please bear with me.</p>
  
  <p><strong>Q1: When working with a 3rd party website, how does one determine what the GET string should be to directly request JSON object?</strong> </p>
  
  <p>This seems like the ideal solution but I do not understand the process of determining how the GET request should be constructed. I have barely scratched the surface of using a Inspector tool in Firefox to investigate html. Using this tool to find the JSON request URL string (for a GET) is a mystery to me. </p>
  
  <p><strong>Q2: When working with a 3rd party website, how does one navigate the Html to find the node where the JSON string can be extracted?</strong> </p>
  
  <p>And this is a backup question. If the answer is that "no, you cannot directly determine the JSON URL GET string", the backup is to traverse the Html and locate the element that contains the JSON data string.</p>
  
  <p><strong>Example of the html:</strong> (heavily truncated to fit here in this post)</p>
  
  <pre><code>...lots of html, followed by:
  
      &lt;script&gt;
        window.dataLayer = window.dataLayer || [];
           function gtag(){dataLayer.push(arguments);}
           gtag('js', new Date());
           gtag('config', 'UA-6441790-1');
      &lt;/script&gt;
      &lt;script&gt;
        var result = {"teams":["tigers","sharks","destroyers","nerfs"]};
      &lt;/script&gt;
  
  ...lots more html, followed by EOF.
  </code></pre>
  
  <p>And the JSON data is encapsulated in the <code>var result</code> string</p>