digitalbazaar/pyld

Compacting failure with @vocab

Opened this issue · 1 comments

Fak3 commented
from pprint import pprint
ctx = {'@vocab': 'http://ex.org/#', 'path': {'@type': '@id'}}
data = {
    'http://ex.org/#maxCount': 1,
    'http://ex.org/#path': 'http://ex.org/#shortname'
}
pprint(jsonld.compact(data, ctx))
# {
#   '@context': {'@vocab': 'http://ex.org/#', 'path': {'@type': '@id'}},
#    # NOTE: maxCount: not declared in context => compacted OK
#   'maxCount': 1
#    # NOTE: path: declared in context => compacting FAILED
#   'http://ex.org/#path': 'http://ex.org/#shortname',
# }
Fak3 commented

One interesting doscovery: if i change 'http://ex.org/#shortname' to {'@id': 'http://ex.org/#shortname'} in the input data json, then property name compaction suddenly works, but the property value still not compacted:

{'@context': {'@vocab': 'http://ex.org/#', 'path': {'@type': '@id'}},
 '@id': '_:b0',
 'maxCount': 1,
 'path': 'http://ex.org/#shortname'}
# Note: `path` is compacted, but its value still isn't