internal static TextLine_internal DeserializeTextLine_internal(JsonElement element) { string text = default; IReadOnlyList <float> boundingBox = default; Language_internal? language = default; IReadOnlyList <TextWord_internal> words = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("text")) { text = property.Value.GetString(); continue; } if (property.NameEquals("boundingBox")) { List <float> array = new List <float>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetSingle()); } boundingBox = array; continue; } if (property.NameEquals("language")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } language = new Language_internal(property.Value.GetString()); continue; } if (property.NameEquals("words")) { List <TextWord_internal> array = new List <TextWord_internal>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(TextWord_internal.DeserializeTextWord_internal(item)); } } words = array; continue; } } return(new TextLine_internal(text, boundingBox, language, words)); }
internal static ReadResult_internal DeserializeReadResult_internal(JsonElement element) { int page = default; float angle = default; float width = default; float height = default; LengthUnit unit = default; Language_internal?language = default; IReadOnlyList <TextLine_internal> lines = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("page")) { page = property.Value.GetInt32(); continue; } if (property.NameEquals("angle")) { angle = property.Value.GetSingle(); continue; } if (property.NameEquals("width")) { width = property.Value.GetSingle(); continue; } if (property.NameEquals("height")) { height = property.Value.GetSingle(); continue; } if (property.NameEquals("unit")) { unit = property.Value.GetString().ToLengthUnit(); continue; } if (property.NameEquals("language")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } language = new Language_internal(property.Value.GetString()); continue; } if (property.NameEquals("lines")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <TextLine_internal> array = new List <TextLine_internal>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(TextLine_internal.DeserializeTextLine_internal(item)); } } lines = array; continue; } } return(new ReadResult_internal(page, angle, width, height, unit, language, lines)); }