【发布时间】:2015-05-15 19:36:26
【问题描述】:
我正在尝试保存这个 json 对象:
[
{
"patient_id": "59b70b0e-51cb-4215-b65a-db470067c8de"
},
[
{
"tel_1_preferred_p": true,
"adr_region": "OK",
"tel_2_number": "800-979-6786",
"__modelname__": "Demographics",
"adr_city": "Bixby",
"ethnicity": null,
"adr_postalcode": "74008",
"name_family": "John",
"name_middle": null,
"tel_1_type": "h",
"tel_2_type": "c",
"name_prefix": null,
"email": "william.robinson@example.com",
"name_given": "Smith",
"adr_street": "23 Church Rd",
"bday": "1965-08-09",
"__documentid__": "65cd1101-b047-4ce5-afc0-778d033229ca",
"tel_1_number": "800-870-3011",
"preferred_language": "EN",
"gender": "male",
"name_suffix": null,
"tel_2_preferred_p": true,
"race": null,
"adr_country": "USA"
}
],
[
{
"startDate": "2014-10-02T00:00:00Z",
"name_identifier": "195967001",
"name_system": null,
"notes": "None",
"name_title": "Asthma",
"__modelname__": "Problem",
"endDate": "2014-10-13T00:00:00Z",
"__documentid__": "eaba4e92-3aaf-4d8c-a7db-8cfd563290c6"
},
{
"startDate": "2014-12-02T00:00:00Z",
"name_identifier": "161155000",
"name_system": null,
"notes": "None",
"name_title": "School problem (finding)",
"__modelname__": "Problem",
"endDate": "2014-12-14T00:00:00Z",
"__documentid__": "3058b12d-434d-48da-8b14-05dd485946cb"
},
{
"startDate": "2008-07-29T00:00:00Z",
"name_identifier": "185903001",
"name_system": "http://purl.bioontology.org/ontology/SNOMEDCT/",
"notes": null,
"name_title": "Needs influenza immunization",
"__modelname__": "Problem",
"endDate": "2010-09-13T00:00:00Z",
"__documentid__": "d982c117-43c3-407f-bd9e-27dc59008938"
}
],
[
{
"name": "Amputation of the foot (procedure)",
"comments": null,
"provider_institution": null,
"date_performed": "2014-10-22T00:00:00Z",
"name_value": "None",
"__modelname__": "Procedure",
"__documentid__": "221df5bd-16a8-4763-9827-06fb305b91e5",
"provider_name": null,
"name_abbrev": "180030006",
"name_type": "http://purl.bioontology.org/ontology/SNOMEDCT/",
"location": null
}
]
]
到 XML 文件或 Python 代码中的 RDF。我没有找到关于 rdf 的帖子,所以我尝试了 XML。我还尝试将列表更改为 dict ,就像在这篇文章中一样:
Python Json loads() returning string instead of dictionary?
但它不起作用。在 views.py 我有:
fileroot = '[{"patient_id":"'+record_id+'"},'+content0+','+content1+','+content2+']'
jsonData = simplejson.loads(fileroot)
它返回 'list' 对象没有属性 'items'。如果我将其更改为:
fileroot = '[{"patient_id":"'+record_id+'"},'+content0+','+content1+','+content2+']'
jsonData = simplejson.loads(fileroot)[0]
它什么也不返回。 我也尝试过这个链接:
https://www.safaribooksonline.com/library/view/python-cookbook-3rd/9781449357337/ch06s05.html
但它不再工作了。
【问题讨论】:
-
你有什么问题?您的 json 文件在我的控制台中运行。
-
我无法将其转换为 XML 或 RDF 并保存