<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: NewtonSoft Deserialize nested JSON in Digital Exchange</title>
    <link>https://community.blueprism.com/t5/Digital-Exchange/NewtonSoft-Deserialize-nested-JSON/m-p/51508#M440</link>
    <description>Hello,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;To accomplish this I used the OCR Response (collection) from the MS vision skill output then looped through the Nested collections the JSON created into sub-collections until i was able to get to the text that I needed then contactinated the text into a Text Data Item.&amp;nbsp;&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="6095.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/6277iA870D14FC9083BD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="6095.png" alt="6095.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Hopefully this help you get the data you looking for.&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Regards, &lt;BR /&gt;&lt;BR /&gt;David Flores&lt;BR /&gt;Sr. Product Consultant&lt;BR /&gt;blue prism&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Mon, 20 Apr 2020 21:37:00 GMT</pubDate>
    <dc:creator>david.flores</dc:creator>
    <dc:date>2020-04-20T21:37:00Z</dc:date>
    <item>
      <title>NewtonSoft Deserialize nested JSON</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/NewtonSoft-Deserialize-nested-JSON/m-p/51507#M439</link>
      <description>&lt;P&gt;please help a doomed soul. I don't understand how to cast each part of the nested json into a datatable. &lt;/P&gt;

&lt;P&gt;I tried creating the public classes using the tool provided at json2csharp.com, and then point to them and write to the data table. &lt;/P&gt;

&lt;P&gt;I also tried by not creating the classes and just convert json directly to the data table.&lt;/P&gt;

&lt;P&gt;With classes: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;DataSet ds = JObject.Parse(json_txt)['recognitionResults'].ToObject();&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Without classes:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;DataTable dt = (DataTable)JsonConvert.DeserializeObject(json_txt, (typeof(DataTable)));&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Classes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;public class Word
{
    public List&amp;lt;double&amp;gt; boundingBox { get; set; }
    public string text { get; set; }
    public string confidence { get; set; }
}

public class Line
{
    public List&amp;lt;double&amp;gt; boundingBox { get; set; }
    public string text { get; set; }
    public List&amp;lt;Word&amp;gt; words { get; set; }
}

public class RecognitionResult
{
    public int page { get; set; }
    public double clockwiseOrientation { get; set; }
    public double width { get; set; }
    public double height { get; set; }
    public string unit { get; set; }
    public List&amp;lt;Line&amp;gt; lines { get; set; }
}

public class RootObject
{
    public string status { get; set; }
    public List&amp;lt;RecognitionResult&amp;gt; recognitionResults { get; set; }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;JSON txt:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;pastebin.com/yBVrLveq&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;For context:&lt;/P&gt;

&lt;P&gt;I used the Microsoft Computer Vision API to recognize text from a PDF. &lt;/P&gt;

&lt;P&gt;If is not possible to map each property of the json file into the datatable, it would be fine to have a table like:&lt;/P&gt;

&lt;P&gt;'page 0' : 'lines'
'page 1' : 'lines'&lt;/P&gt;

&lt;P&gt;Each set of 'lines' contains a variable number of lines. That's what I mean by nested. &lt;/P&gt;

--------------------------------------------------&lt;BR /&gt;

&lt;B&gt;Disclaimer:&lt;/B&gt; This content was auto-posted from Stackoverflow. The original Stackoverflow question is here &lt;A href="https://stackoverflow.com/questions/57518439/newtonsoft-deserialize-nested-json"&gt;Stackoverflow Post&lt;/A&gt;, posted by &lt;A href="https://stackoverflow.com/users/11934077/david-vizcaino"&gt;David Vizcaino&lt;/A&gt;.</description>
      <pubDate>Fri, 16 Aug 2019 14:31:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/NewtonSoft-Deserialize-nested-JSON/m-p/51507#M439</guid>
      <dc:creator>Digital_WorkerB</dc:creator>
      <dc:date>2019-08-16T14:31:00Z</dc:date>
    </item>
    <item>
      <title>RE: NewtonSoft Deserialize nested JSON</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/NewtonSoft-Deserialize-nested-JSON/m-p/51508#M440</link>
      <description>Hello,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;To accomplish this I used the OCR Response (collection) from the MS vision skill output then looped through the Nested collections the JSON created into sub-collections until i was able to get to the text that I needed then contactinated the text into a Text Data Item.&amp;nbsp;&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="6095.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/6277iA870D14FC9083BD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="6095.png" alt="6095.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Hopefully this help you get the data you looking for.&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Regards, &lt;BR /&gt;&lt;BR /&gt;David Flores&lt;BR /&gt;Sr. Product Consultant&lt;BR /&gt;blue prism&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Apr 2020 21:37:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/NewtonSoft-Deserialize-nested-JSON/m-p/51508#M440</guid>
      <dc:creator>david.flores</dc:creator>
      <dc:date>2020-04-20T21:37:00Z</dc:date>
    </item>
  </channel>
</rss>

