internal static DataTable DeserializeDataTable(JsonElement element)
        {
            int rows    = default;
            int columns = default;
            IReadOnlyList <DataTableCell> cells = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("rows"))
                {
                    rows = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("columns"))
                {
                    columns = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("cells"))
                {
                    List <DataTableCell> array = new List <DataTableCell>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DataTableCell.DeserializeDataTableCell(item));
                    }
                    cells = array;
                    continue;
                }
            }
            return(new DataTable(rows, columns, cells));
        }
Пример #2
0
 internal FormTableCell(DataTableCell dataTableCell, IReadOnlyList <ReadResult> readResults, int pageNumber)
     : base(new BoundingBox(dataTableCell.BoundingBox), pageNumber, dataTableCell.Text)
 {
     ColumnIndex   = dataTableCell.ColumnIndex;
     ColumnSpan    = dataTableCell.ColumnSpan ?? 1;
     Confidence    = dataTableCell.Confidence;
     IsFooter      = dataTableCell.IsFooter ?? false;
     IsHeader      = dataTableCell.IsHeader ?? false;
     RowIndex      = dataTableCell.RowIndex;
     RowSpan       = dataTableCell.RowSpan ?? 1;
     FieldElements = dataTableCell.Elements != null
         ? FormField.ConvertTextReferences(dataTableCell.Elements, readResults)
         : new List <FormElement>();
 }