internal static TextWord_internal DeserializeTextWord_internal(JsonElement element)
        {
            TextWord_internal result = new TextWord_internal();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("text"))
                {
                    result.Text = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("boundingBox"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.BoundingBox.Add(item.GetSingle());
                    }
                    continue;
                }
                if (property.NameEquals("confidence"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Confidence = property.Value.GetSingle();
                    continue;
                }
            }
            return(result);
        }
Esempio n. 2
0
        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));
        }