-
Notifications
You must be signed in to change notification settings - Fork 134
Description
Consider the following code:
CTX={ "foo": "http://example.com/foo"}
expanded = jsonld.expand({"fooo":"bar"}, {'expandContext': CTX})
The result is an empty list, because "fooo" is not recognized by CTX. The fact that it is silently ignore can be relevant in some situations, but in not in others. In this example, it is probably a typo, which the user would probably like to be detected.
So I think there should be a way to be notified when some JSON attributes were ignored.
The simplest (but not flexible) way to do it would be to have a strict
option, defaulting to False. When set to True, an exception would be raised whenever a JSON key could not be converted to a IRI. In my application, I would rather fail than silently drop some data submitted by the user.
A more flexible solution would be to have a droppedKeys
option, expecting a set, and populating this set with every key that could not be converted to an IRI.
CTX={ "foo": "http://example.com/foo"}
dropped = set()
expanded = jsonld.expand({"fooo":"bar"}, {'expandContext': CTX, 'droppedKeys': dropped})
if dropped:
# print some warning message to the user
# but still process expended