예제 #1
0
        internal static DocumentResult_internal DeserializeDocumentResult_internal(JsonElement element)
        {
            DocumentResult_internal result = new DocumentResult_internal();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("docType"))
                {
                    result.DocType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("pageRange"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.PageRange.Add(item.GetInt32());
                    }
                    continue;
                }
                if (property.NameEquals("fields"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        result.Fields.Add(property0.Name, FieldValue_internal.DeserializeFieldValue_internal(property0.Value));
                    }
                    continue;
                }
            }
            return(result);
        }
예제 #2
0
        internal static DocumentResult DeserializeDocumentResult(JsonElement element)
        {
            string              docType           = default;
            Optional <Guid>     modelId           = default;
            IReadOnlyList <int> pageRange         = default;
            Optional <float>    docTypeConfidence = default;
            IReadOnlyDictionary <string, FieldValue_internal> fields = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("docType"))
                {
                    docType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("modelId"))
                {
                    modelId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("pageRange"))
                {
                    List <int> array = new List <int>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetInt32());
                    }
                    pageRange = array;
                    continue;
                }
                if (property.NameEquals("docTypeConfidence"))
                {
                    docTypeConfidence = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("fields"))
                {
                    Dictionary <string, FieldValue_internal> dictionary = new Dictionary <string, FieldValue_internal>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, FieldValue_internal.DeserializeFieldValue_internal(property0.Value));
                        }
                    }
                    fields = dictionary;
                    continue;
                }
            }
            return(new DocumentResult(docType, Optional.ToNullable(modelId), pageRange, Optional.ToNullable(docTypeConfidence), fields));
        }
예제 #3
0
        internal static DocumentResult_internal DeserializeDocumentResult_internal(JsonElement element)
        {
            string docType = default;
            IReadOnlyList <int> pageRange = new List <int>();
            IReadOnlyDictionary <string, FieldValue_internal> fields = new Dictionary <string, FieldValue_internal>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("docType"))
                {
                    docType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("pageRange"))
                {
                    List <int> array = new List <int>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetInt32());
                    }
                    pageRange = array;
                    continue;
                }
                if (property.NameEquals("fields"))
                {
                    Dictionary <string, FieldValue_internal> dictionary = new Dictionary <string, FieldValue_internal>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, FieldValue_internal.DeserializeFieldValue_internal(property0.Value));
                    }
                    fields = dictionary;
                    continue;
                }
            }
            return(new DocumentResult_internal(docType, pageRange, fields));
        }