gpt4 book ai didi

hl7-fhir - 使用 .net API 将 FHIR 资源序列化为 JSON

转载 作者:行者123 更新时间:2023-12-04 18:07:29 25 4
gpt4 key购买 nike

我试图使用 FHIR .net API ( https://github.com/ewoutkramer/fhir-net-api) 解析 XML 文件,然后将其序列化为 JSON。

Bundle inputBundle = FhirParser.ParseBundleFromXml(inputStream);
Console.WriteLine(FhirSerializer.SerializeBundleToJson(inputBundle));

第一行工作正常,我可以看到包的 XML 文件已被解析并位于“inputBundle”对象中。

然而,当我将它序列化为 JSON(代码的第二行)时,我得到了一个错误

  System.ArgumentException: Can not add property resourceType to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.
at Newtonsoft.Json.Linq.JObject.ValidateToken(JToken o, JToken existing)
at Newtonsoft.Json.Linq.JContainer.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
at Newtonsoft.Json.Linq.JObject.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
at Newtonsoft.Json.Linq.JContainer.AddInternal(Int32 index, Object content, Boolean skipParentCheck)
at Newtonsoft.Json.Linq.JContainer.Add(Object content)
at Hl7.Fhir.Serialization.JsonDomFhirWriter.WriteStartProperty(String name) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\JsonDomFhirWriter.cs:line 42
at Hl7.Fhir.Serialization.ComplexTypeWriter.write(ClassMapping mapping, Object instance, PropertyMapping prop, SerializationMode mode) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\ComplexTypeWriter.cs:line 75
at Hl7.Fhir.Serialization.ComplexTypeWriter.Serialize(ClassMapping mapping, Object instance, SerializationMode mode) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\ComplexTypeWriter.cs:line 48
at Hl7.Fhir.Serialization.ResourceWriter.Serialize(Object instance, Boolean contained) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\ResourceWriter.cs:line 35
at Hl7.Fhir.Serialization.BundleJsonSerializer.getContentsAsJObject(Resource resource, Boolean summary) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\BundleJsonSerializer.cs:line 141
at Hl7.Fhir.Serialization.BundleJsonSerializer.createEntry(BundleEntry entry, Boolean summary) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\BundleJsonSerializer.cs:line 94
at Hl7.Fhir.Serialization.BundleJsonSerializer.WriteTo(Bundle bundle, JsonWriter writer, Boolean summary) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\BundleJsonSerializer.cs:line 43
at Hl7.Fhir.Serialization.FhirSerializer.<>c__DisplayClassd.<SerializeBundleToJson>b__c(JsonWriter jw) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\FhirSerializer.cs:line 115
at Hl7.Fhir.Serialization.FhirSerializer.jsonWriterToString(Action`1 serializer) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\FhirSerializer.cs:line 198
at Hl7.Fhir.Serialization.FhirSerializer.SerializeBundleToJson(Bundle bundle, Boolean summary) in D:\BENBUN_CODE\FHIR\fhir-net-api-client-DSTU-update\src\Hl7.Fhir.Api\Serialization\FhirSerializer.cs:line 115
at fhirjx.Program.processFiles() in C:\Users\RichardKavanagh\documents\visual studio 2010\Projects\fhirjx\fhirjx\Program.cs:line 121

有关信息,我使用的 XML 文件直接取自 http://www.hl7.org/implement/standards/fhir/query-example-response.xml.html

知道哪里出了问题吗?

最佳答案

您没有做错任何事情,这显然是一个错误。你介意在这里举报吗? https://github.com/ewoutkramer/fhir-net-api/issues?state=open

关于hl7-fhir - 使用 .net API 将 FHIR 资源序列化为 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23247476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com