diff --git a/iiif_prezi3/base.py b/iiif_prezi3/base.py index 67a6d1a..3648df9 100644 --- a/iiif_prezi3/base.py +++ b/iiif_prezi3/base.py @@ -53,12 +53,17 @@ def json(self, **kwargs): def jsonld(self, **kwargs): # approach 6- use the pydantic .dict() function to get the dict with pydantic options, add the context at the top and dump to json with modified kwargs - pydantic_args = ["include", "exclude", "by_alias", "encoder"] + excluded_args = ["exclude_unset", "exclude_defaults", "exclude_none", "by_alias"] + pydantic_args = ["include", "exclude", "encoder"] dict_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg in pydantic_args]) - json_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg not in pydantic_args]) - return json.dumps({"@context": "http://iiif.io/api/presentation/3/context.json", **self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)}, **json_kwargs) + + json_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg not in pydantic_args + excluded_args]) + return json.dumps({"@context": "http://iiif.io/api/presentation/3/context.json", + **self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)}, **json_kwargs) def jsonld_dict(self, **kwargs): - pydantic_args = ["include", "exclude", "by_alias", "encoder"] + pydantic_args = ["include", "exclude", "encoder"] dict_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg in pydantic_args]) - return {"@context": "http://iiif.io/api/presentation/3/context.json", **self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)} + + return {"@context": "http://iiif.io/api/presentation/3/context.json", + **self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)}