admin管理员组文章数量:1399509
Want to persist, in c#, the result of a document analysis and rehydrate back to result model at later time/date.
Generate a document analysis in the standard manner using:
Operation<AnalyzeResult> operation = await _client.AnalyzeDocumentAsync(WaitUntil.Completed, options);
AnalyzeResult result = operation.Value;
Am processing results from this analysis, but would like to save the analysis result to rehydrate.
Have seen working examples in python and various internal methods within the AnalyzeResult and IJsonModel c# implementations, but cannot find a reference or way in to both Write and Read into the AnalyzeResult class
All possible construction methods in AnalyzeResult appear to be internal and suffer similar problem when using class as type IJsonModel
Don't really want to do via reflection.
Would expect being able to serialize/deserialize in some manner as when using batch processing associated with storage accounts the result is stored as json in the container.
Want to persist, in c#, the result of a document analysis and rehydrate back to result model at later time/date.
Generate a document analysis in the standard manner using:
Operation<AnalyzeResult> operation = await _client.AnalyzeDocumentAsync(WaitUntil.Completed, options);
AnalyzeResult result = operation.Value;
Am processing results from this analysis, but would like to save the analysis result to rehydrate.
Have seen working examples in python and various internal methods within the AnalyzeResult and IJsonModel c# implementations, but cannot find a reference or way in to both Write and Read into the AnalyzeResult class
All possible construction methods in AnalyzeResult appear to be internal and suffer similar problem when using class as type IJsonModel
Don't really want to do via reflection.
Would expect being able to serialize/deserialize in some manner as when using batch processing associated with storage accounts the result is stored as json in the container.
Share Improve this question edited Mar 26 at 16:45 TylerH 21.1k78 gold badges79 silver badges114 bronze badges asked Mar 26 at 16:42 Alan EveryAlan Every 31 silver badge2 bronze badges1 Answer
Reset to default 0This can be done using the ModelReaderWriter type or using System.Text.Json
with the JsonModelConverter registered.
An example of both approaches can be found in System.ClientModel-based ModelReaderWriter samples.
Applied to your scenario, this would look something like:
ModelReaderWriter
// Serialize the result
AnayzeResult model = operation.Value;
BinaryData data = ModelReaderWriter.Write(model);
// Deserialize
string jsonFromStorage = GetSerializedResult();
AnayzeResult? model =
ModelReaderWriter.Read<AnayzeResult>(BinaryData.FromString(json));
System.Text.Json
// Serialize the result
AnayzeResult model = operation.Value;
string data = JsonSerializer.Serialize(model,
new JsonSerializerOptions()
{
Converters = { new JsonModelConverter() }
});
// Deserialize
string jsonFromStorage = GetSerializedResult();
AnayzeResult? model =
JsonSerializer.Deserialize<AnalyzeResult>(json,
new JsonSerializerOptions()
{
Converters = { new JsonModelConverter() }
});
本文标签: How do I save and later load Azure DocumentIntelligence AnalyzeResult in cStack Overflow
版权声明:本文标题:How do I save and later load Azure DocumentIntelligence AnalyzeResult in c# - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744138111a2592492.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论