- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-08-19 03:31 PM
please help a doomed soul. I don't understand how to cast each part of the nested json into a datatable.
I tried creating the public classes using the tool provided at json2csharp.com, and then point to them and write to the data table.
I also tried by not creating the classes and just convert json directly to the data table.
With classes:
DataSet ds = JObject.Parse(json_txt)['recognitionResults'].ToObject();
Without classes:
DataTable dt = (DataTable)JsonConvert.DeserializeObject(json_txt, (typeof(DataTable)));
Classes:
public class Word
{
public List<double> boundingBox { get; set; }
public string text { get; set; }
public string confidence { get; set; }
}
public class Line
{
public List<double> boundingBox { get; set; }
public string text { get; set; }
public List<Word> 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<Line> lines { get; set; }
}
public class RootObject
{
public string status { get; set; }
public List<RecognitionResult> recognitionResults { get; set; }
}
JSON txt:
pastebin.com/yBVrLveq
For context:
I used the Microsoft Computer Vision API to recognize text from a PDF.
If is not possible to map each property of the json file into the datatable, it would be fine to have a table like:
'page 0' : 'lines' 'page 1' : 'lines'
Each set of 'lines' contains a variable number of lines. That's what I mean by nested.
--------------------------------------------------Disclaimer: This content was auto-posted from Stackoverflow. The original Stackoverflow question is here Stackoverflow Post, posted by David Vizcaino.
Answered! Go to Answer.
Helpful Answers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-04-20 10:37 PM
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.
Hopefully this help you get the data you looking for.
------------------------------
Regards,
David Flores
Sr. Product Consultant
blue prism
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-04-20 10:37 PM
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.
Hopefully this help you get the data you looking for.
------------------------------
Regards,
David Flores
Sr. Product Consultant
blue prism
------------------------------
