Skip to content

Commit f2fcf2a

Browse files
Merge pull request #64 from apdavison/handle-expanded-paths
Handle expanded IRIs as keys in JSON-LD documents
2 parents 09b53e0 + ac5ae6f commit f2fcf2a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pipeline/src/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,18 @@ def from_jsonld(cls, data, ignore_unexpected_keys=False):
129129
if issubclass(cls, LinkedMetadata):
130130
deserialized_data["id"] = data_copy.pop("@id", None)
131131
for property in cls.properties:
132-
if property.path in data_copy: # todo: use context to resolve uris
132+
found = False
133+
if property.path in data_copy:
133134
value = data_copy.pop(property.path)
135+
found = True
136+
else:
137+
# todo: implement or import a function that does a full JSON-LD expansion
138+
# not just this special case
139+
expanded_path = f"{cls.context['@vocab']}{property.path}"
140+
if expanded_path in data_copy:
141+
value = data_copy.pop(expanded_path)
142+
found = True
143+
if found:
134144
if value:
135145
deserialized_data[property.name] = property.deserialize(value)
136146
else:

0 commit comments

Comments
 (0)