Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object gets serialized as null instead of empty dict #115

Open
ev-agelos opened this issue Dec 23, 2022 · 1 comment
Open

Object gets serialized as null instead of empty dict #115

ev-agelos opened this issue Dec 23, 2022 · 1 comment

Comments

@ev-agelos
Copy link

  • fhir.resources version:
  • Python version:
  • Operating System:

Description

I was expecting an empty object to be serialized to empty dict instead gets serialized as null.

What I Did

from fhir.resources.careteam import CareTeamParticipant
CareTeamParticipant(role=[{}]).json()
# output: '{"role":[null]}'
# I was expecting it to be: '{"role":[{}]}'
@biagiodistefano
Copy link

I have encountered this bug as well.

This issue is relevant because sometimes it makes it impossible to serialize a resource and then load it again, as the serialization creates an invalid resource.

For instance, a resource is serialized as follows:

{
	"fullUrl": "urn:uuid:ff258b30-915f-4561-b356-7b30e7a9393a",
	"resource": {
		"resourceType": "Immunization",
		"id": "ff258b30-915f-4561-b356-7b30e7a9393a",
		"meta": {
			"profile": [
				"https://fhir.kbv.de/StructureDefinition/KBV_PR_MIO_Vaccination_Record_Prime|1.1.0"
			]
		},
		"text": {
			"status": "extensions",
			"div": "<div>\n                        <div/></div>",
			"_div": {
				"extension": [
					null
				]
			}
		},
...
}

And then when trying to load from the json:

[[ErrorWrapper(exc=ValidationError(model='BundleEntry', errors=[{'loc': ('resource', 'text', '_div', 'extension', 0), 'msg': 'none is not an allowed value', 'type': 'type_error.none.not_allowed'}]), loc=('entry', 6))]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants