internal static MultiClassificationDocumentResult DeserializeMultiClassificationDocumentResult(JsonElement element) { IList <ClassificationResult> @class = default; string id = default; IList <DocumentWarning> warnings = default; Optional <TextDocumentStatistics> statistics = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("class")) { List <ClassificationResult> array = new List <ClassificationResult>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(ClassificationResult.DeserializeClassificationResult(item)); } @class = array; continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("warnings")) { List <DocumentWarning> array = new List <DocumentWarning>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(DocumentWarning.DeserializeDocumentWarning(item)); } warnings = array; continue; } if (property.NameEquals("statistics")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value); continue; } } return(new MultiClassificationDocumentResult(id, warnings, Optional.ToNullable(statistics), @class)); }
internal static SingleClassificationDocument DeserializeSingleClassificationDocument(JsonElement element) { string id = default; ClassificationResult classification = default; IReadOnlyList <TextAnalyticsWarningInternal> warnings = default; Optional <TextDocumentStatistics> statistics = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("classification")) { classification = ClassificationResult.DeserializeClassificationResult(property.Value); continue; } if (property.NameEquals("warnings")) { List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item)); } warnings = array; continue; } if (property.NameEquals("statistics")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value); continue; } } return(new SingleClassificationDocument(id, classification, warnings, Optional.ToNullable(statistics))); }