【发布时间】:2016-08-03 15:02:20
【问题描述】:
我有一个约会 json,我需要将其转换为 DSTU2 HAPI FHIR json 对象。任何可用于相同的标准库?谷歌 gson 库有效,但没有为字段中的对象赋予价值
{
"resourceType": "Appointment",
"id": "",
"status": "proposed",
"reason": {
"text": "Regular checkup"
},
"description": "",
"slot": [
{
"reference": "bfgf5dfdf4e45g"
}
],
"comment": "Regular yearly visit",
"participant": [
{
"actor": {
"reference": "9sdfsndjkfnksdfu3yyugbhjasbd"
},
"required": "required"
},
{
"actor": {
"reference": "78hjkdfgdfg223vg"
},
"required": "required"
},
{
"actor": {
"reference": "sdfs3df5sdfdfgdf"
},
"required": "required"
}
]
}
需要将上面的 json 转换为我使用的 ca.uhn.fhir.model.dstu2.resource.Appointment 类
Appointment appointment = new Gson().fromJson(map.get("appointment"), Appointment.class);
但它提供了带有空字段的约会对象
【问题讨论】:
-
预期的最终结果是什么 - 拥有一个包含所有字段的约会类?然后创建 Appointment 类并填充字段。它可能需要不止一行代码,但至少你实现了你所需要的。
标签: gson hl7-fhir hapi hapi-fhir