digitalbazaar/pyld

Normalization

sharpaper opened this issue · 2 comments

Is it possible to normalize a document such that for example it always contains @graph, or such that a link is always contained in a list for example "knows": "_:alice" becomes "knows": [ "_:alice" ]? Flattening doesn't seem to help in this regard, because nodes are no longer nested which makes it more difficult to parse. .normalize() also doesn't seem to be what I'm looking for, since it outputs a list of tuples. My problem is that when I retrieve a jsonld document, it can contain @graph or not, and the object of a property can be a string, a list, or an object, depending how it was serialized. Parsing a jsonld object is not fun because of this variability, so it would be very useful to have a way to normalize a json object.

mmm I think this could be what I'm looking for?

Try using ”@type”: “@none” in the term definition for values you want to keep expanded when compacting, possibly also using ”@container”: “@set”.