internal static CopyResult DeserializeCopyResult(JsonElement element) { Guid modelId = default; Optional <IReadOnlyList <FormRecognizerError> > errors = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("modelId")) { modelId = property.Value.GetGuid(); continue; } if (property.NameEquals("errors")) { List <FormRecognizerError> array = new List <FormRecognizerError>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(FormRecognizerError.DeserializeFormRecognizerError(item)); } errors = array; continue; } } return(new CopyResult(modelId, Optional.ToList(errors))); }
internal static TrainResult_internal DeserializeTrainResult_internal(JsonElement element) { IReadOnlyList <TrainingDocumentInfo> trainingDocuments = default; IReadOnlyList <CustomFormModelField> fields = default; float?averageModelAccuracy = default; IReadOnlyList <FormRecognizerError> errors = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("trainingDocuments")) { List <TrainingDocumentInfo> array = new List <TrainingDocumentInfo>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item)); } trainingDocuments = array; continue; } if (property.NameEquals("fields")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <CustomFormModelField> array = new List <CustomFormModelField>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(CustomFormModelField.DeserializeCustomFormModelField(item)); } fields = array; continue; } if (property.NameEquals("averageModelAccuracy")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } averageModelAccuracy = property.Value.GetSingle(); continue; } if (property.NameEquals("errors")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <FormRecognizerError> array = new List <FormRecognizerError>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(FormRecognizerError.DeserializeFormRecognizerError(item)); } errors = array; continue; } } return(new TrainResult_internal(trainingDocuments, fields, averageModelAccuracy, errors)); }
internal ErrorResponse(FormRecognizerError error) { if (error == null) { throw new ArgumentNullException(nameof(error)); } Error = error; }
internal static TrainResult DeserializeTrainResult(JsonElement element) { IReadOnlyList <TrainingDocumentInfo> trainingDocuments = default; Optional <IReadOnlyList <CustomFormModelField> > fields = default; Optional <float> averageModelAccuracy = default; Optional <Guid> modelId = default; Optional <IReadOnlyList <FormRecognizerError> > errors = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("trainingDocuments")) { List <TrainingDocumentInfo> array = new List <TrainingDocumentInfo>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item)); } trainingDocuments = array; continue; } if (property.NameEquals("fields")) { List <CustomFormModelField> array = new List <CustomFormModelField>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(CustomFormModelField.DeserializeCustomFormModelField(item)); } fields = array; continue; } if (property.NameEquals("averageModelAccuracy")) { averageModelAccuracy = property.Value.GetSingle(); continue; } if (property.NameEquals("modelId")) { modelId = property.Value.GetGuid(); continue; } if (property.NameEquals("errors")) { List <FormRecognizerError> array = new List <FormRecognizerError>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(FormRecognizerError.DeserializeFormRecognizerError(item)); } errors = array; continue; } } return(new TrainResult(trainingDocuments, Optional.ToList(fields), Optional.ToNullable(averageModelAccuracy), Optional.ToNullable(modelId), Optional.ToList(errors))); }
internal static TrainResult_internal DeserializeTrainResult_internal(JsonElement element) { TrainResult_internal result = new TrainResult_internal(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("trainingDocuments")) { foreach (var item in property.Value.EnumerateArray()) { result.TrainingDocuments.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item)); } continue; } if (property.NameEquals("fields")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Fields = new List <FieldPredictionAccuracy>(); foreach (var item in property.Value.EnumerateArray()) { result.Fields.Add(FieldPredictionAccuracy.DeserializeFieldPredictionAccuracy(item)); } continue; } if (property.NameEquals("averageModelAccuracy")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.AverageModelAccuracy = property.Value.GetSingle(); continue; } if (property.NameEquals("errors")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Errors = new List <FormRecognizerError>(); foreach (var item in property.Value.EnumerateArray()) { result.Errors.Add(FormRecognizerError.DeserializeFormRecognizerError(item)); } continue; } } return(result); }
internal static ErrorResponse_internal DeserializeErrorResponse_internal(JsonElement element) { ErrorResponse_internal result = new ErrorResponse_internal(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("error")) { result.Error = FormRecognizerError.DeserializeFormRecognizerError(property.Value); continue; } } return(result); }
internal static ErrorResponse DeserializeErrorResponse(JsonElement element) { FormRecognizerError error = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("error")) { error = FormRecognizerError.DeserializeFormRecognizerError(property.Value); continue; } } return(new ErrorResponse(error)); }
internal static FormRecognizerError DeserializeFormRecognizerError(JsonElement element) { FormRecognizerError result = new FormRecognizerError(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("code")) { result.Code = property.Value.GetString(); continue; } if (property.NameEquals("message")) { result.Message = property.Value.GetString(); continue; } } return(result); }
internal static AnalyzeResult_internal DeserializeAnalyzeResult_internal(JsonElement element) { AnalyzeResult_internal result = new AnalyzeResult_internal(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("version")) { result.Version = property.Value.GetString(); continue; } if (property.NameEquals("readResults")) { foreach (var item in property.Value.EnumerateArray()) { result.ReadResults.Add(ReadResult_internal.DeserializeReadResult_internal(item)); } continue; } if (property.NameEquals("pageResults")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.PageResults = new List <PageResult_internal>(); foreach (var item in property.Value.EnumerateArray()) { result.PageResults.Add(PageResult_internal.DeserializePageResult_internal(item)); } continue; } if (property.NameEquals("documentResults")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.DocumentResults = new List <DocumentResult_internal>(); foreach (var item in property.Value.EnumerateArray()) { result.DocumentResults.Add(DocumentResult_internal.DeserializeDocumentResult_internal(item)); } continue; } if (property.NameEquals("errors")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Errors = new List <FormRecognizerError>(); foreach (var item in property.Value.EnumerateArray()) { result.Errors.Add(FormRecognizerError.DeserializeFormRecognizerError(item)); } continue; } } return(result); }
internal static AnalyzeResult_internal DeserializeAnalyzeResult_internal(JsonElement element) { string version = default; IReadOnlyList <ReadResult_internal> readResults = default; IReadOnlyList <PageResult_internal> pageResults = default; IReadOnlyList <DocumentResult_internal> documentResults = default; IReadOnlyList <FormRecognizerError> errors = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("version")) { version = property.Value.GetString(); continue; } if (property.NameEquals("readResults")) { List <ReadResult_internal> array = new List <ReadResult_internal>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(ReadResult_internal.DeserializeReadResult_internal(item)); } } readResults = array; continue; } if (property.NameEquals("pageResults")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <PageResult_internal> array = new List <PageResult_internal>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(PageResult_internal.DeserializePageResult_internal(item)); } } pageResults = array; continue; } if (property.NameEquals("documentResults")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <DocumentResult_internal> array = new List <DocumentResult_internal>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(DocumentResult_internal.DeserializeDocumentResult_internal(item)); } } documentResults = array; continue; } if (property.NameEquals("errors")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <FormRecognizerError> array = new List <FormRecognizerError>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(FormRecognizerError.DeserializeFormRecognizerError(item)); } } errors = array; continue; } } return(new AnalyzeResult_internal(version, readResults, pageResults, documentResults, errors)); }
internal static V2AnalyzeResult DeserializeV2AnalyzeResult(JsonElement element) { string version = default; Optional <IReadOnlyList <ReadResult> > readResults = default; Optional <IReadOnlyList <PageResult> > pageResults = default; Optional <IReadOnlyList <DocumentResult> > documentResults = default; Optional <IReadOnlyList <FormRecognizerError> > errors = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("version")) { version = property.Value.GetString(); continue; } if (property.NameEquals("readResults")) { if (property.Value.ValueKind == JsonValueKind.Null) { readResults = null; continue; } List <ReadResult> array = new List <ReadResult>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(ReadResult.DeserializeReadResult(item)); } readResults = array; continue; } if (property.NameEquals("pageResults")) { if (property.Value.ValueKind == JsonValueKind.Null) { pageResults = null; continue; } List <PageResult> array = new List <PageResult>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(PageResult.DeserializePageResult(item)); } pageResults = array; continue; } if (property.NameEquals("documentResults")) { if (property.Value.ValueKind == JsonValueKind.Null) { documentResults = null; continue; } List <DocumentResult> array = new List <DocumentResult>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(DocumentResult.DeserializeDocumentResult(item)); } documentResults = array; continue; } if (property.NameEquals("errors")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <FormRecognizerError> array = new List <FormRecognizerError>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(FormRecognizerError.DeserializeFormRecognizerError(item)); } errors = array; continue; } } return(new V2AnalyzeResult(version, Optional.ToList(readResults), Optional.ToList(pageResults), Optional.ToList(documentResults), Optional.ToList(errors))); }