json-ld / json-ld.org

JSON for Linked Data's documentation and playground site
https://json-ld.org/
Other
856 stars 152 forks source link

Representing string maps in RDF #709

Open iddan opened 4 years ago

iddan commented 4 years ago

Currently, maps of dynamic string keys can only be represented by an rdf:JSON literal this works for translating JSON-LD to Linked Data Dataset and vice versa but it makes the data unstructured (as it is just a literal).

{ "@id": "http://example.org/with-map", "http://example.org/map": { "a": "b" } }

Will be translated to

<http://example.org/with-map> <http://example.org/map> "{ \"a\": \"b\" }"^^rdf:JSON .

But what if instead they would be parsed to RDF data:

<http://example.org/with-map> <http://example.org/map> _:map .
_:map rdf:type rdf:Map .
_:map rdf:_1 _:entry1 .
_:entry1 rdf:key "a" .
_:entry1 rdf:value "b" .

My suggestion is based on an answer gave me in Stackoverflow

gkellogg commented 4 years ago

You might want to move this over to https://github.com/w3c/json-ld-bp if you think this belongs as a JSON-LD Best Practice.

But, note that JSON-LD does support indexing on property values, language or many other things natively, but this is outside of RDF Schema.

Something like schema:Property may also be a useful structure.

iddan commented 4 years ago

I’d like to suggest it as part of the JSON-LD representation in the linked data model. When parsing JSON-LD into a dataset, there should be a way to represent dynamic key maps like you can represent lists