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

LocalName, SlotDefinition #15

Open
cbizon opened this issue Dec 4, 2020 · 1 comment
Open

LocalName, SlotDefinition #15

cbizon opened this issue Dec 4, 2020 · 1 comment

Comments

@cbizon
Copy link
Contributor

cbizon commented Dec 4, 2020

We return a json representation of an element.

So we do something like as_dict(bmt.get_element(element_name)) and then turn that into JSON.

But there are some values of that dict that contain un-jsonable elements (LocalName, SlotDefinition). At the moment, I've just filtered out those element keys, but it would be pretty straightforward to clean that up and convert those entities into dictionaries as well.

Brought up to BMT here: biolink/biolink-model-toolkit#21

Depending on how that is resolved or not, we might take different approaches.

@deepakunni3
Copy link

deepakunni3 commented Dec 17, 2020

How is as_dict implemented?

The following works for me when I want to serialize nested objects:

import json

def to_dict(obj):
    return json.loads(json.dumps(obj, default=lambda o: o.__dict__))

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