-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignoring semantically meaningless nesting #246
Comments
There are several reasons why this might be a good idea, although it's pretty late in the process to be making such changes. Unfortunately, it's not as simple as setting
This would allow us to handle JSON syntaxes such as Microdata-JSON, which use a "properties" keyword and store all the properties underneath:
In this case, aliasing "items" to "@graph", "type" to "@type", "properties" as a reverse index and "@vocab" to http://schema.org/ would pretty much just make this valid JSON-LD. If we were going to make some changes to the spec, we could also re-consider something like id-maps
A similar idea was rejected in September: http://json-ld.org/minutes/2012-09-04/#resolution-1 |
Thanks for the good remarks and the excellent example, @gkellogg! Of course, this is "only" a syntax question, but I think the suggested "@container":"@reverseindex" structure seem slightly complicated. How about defining instead a new term @keytype for defining the type of the key and use it as follows: {"@context": {"indexkey":{"@keytype":"@index"}}} with a shorthand representation: {"@context": {"indexkey":"@index"}} The keyword @type is used in @context context for defining the type of the value so I think this @keytype would be quite logical and would avoid defining a reverse keyword like @reverseindex. Regarding the alias issue: @index keyword is only used inside @context and therefore I don't see why it should be needed to make an alias of the @index keyword. I think the alias mechanism is only relevant when the aliased keywords will be used outside the @context definition (e.g., alias of @id or @type). |
@gkellogg Wondering if the |
Hi Rick, |
For a first-cut at implementing this, I'm expanding {
"@context": {
"@vocab": "http://example/",
"idindex": {"@container": "@id"},
"typeindex": {"@container": "@type"},
"iriindex": {"@container": "prop"}
},
"idindex": {
"a": {"label": "Object with @id 'a'"},
"_:b": {"label": "Object with @id '_:b'"}
},
"typeindex": {
"a": {"label": "Object with @type 'a'"},
"_:b": {"label": "Object with @type '_:b'"}
},
"iriindex": {
"a": {"label": "Object with <prop> 'a'"},
"_:b": {"label": "Object with <prop> '_:b'"}
}
} Which would expand to something like the following: [{
"http://example/idindex": [
{"@id": "a", "http://example/label": [{"@value": "Object with @id 'a'"}]},
{"@id": "_:b", "http://example/label": [{"@value": "Object with @id '_:b'"}]}
],
"http://example/typeindex": [
{"@type": "a", "http://example/label": [{"@value": "Object with @type 'a'"}]},
{"@type": "_:b", "http://example/label": [{"@value": "Object with @type '_:b'"}]}
],
"http://example/iriindex": [
{"http://example/prop": "a", "http://example/label": [{"@value": "Object with <prop> 'a'"}]},
{"http://example/prop": "_:b", "http://example/label": [{"@value": "Object with <prop> '_:b'"}]}
]
}] There are corner-cases for expansion when the property used as an index also appears within the object value. And for compaction, when the index item has more than one value, or value is not an IRI or Blank Node (either it's an error, or use the first value as an index based on input ordering). Note that this does not yet consider |
So, I've spent some time trying to make indexing work for arbitrary keys. While, in principle, it's possible, the complexity for arbitrary properties is proving to be more complex than seems reasonable:
In the end, I think the complexity involved is too great. I am, however, proceeding to allow indexing on |
Thank you very much for considering the feature suggested in the opening of this thread (and in different forms by others, too). It has been a few years since I wrote the opening to this thread so remembering the details took some time. The original idea was, as I interpret myself :), the following: Problem: How to make it possible to group JSON-LD properties (especially if the RDF subject object contains hundreds of properties). Solution suggestion (trying to reformat it to make it more clear and easier to understand, with some new suggestions):
Which would generate the following RDF triplets:
If both groups contains a key with the same IRI interpretation, this would create two RDF triplets. By allowing vocabulary overrides, the property IRIs could be different between groups. Do you think this could work? As far as I know, this can not be made with the current version of JSON-LD (although I have not been working that much with JSON-LD for the past year or so, so I am a bit rusty in JSON-LD at the moment). |
Okay, perhaps because of the original statement, this issue and #430 are confused. #430 is concerned with extending the existing I'll move the other discussion to #430. |
The way I read digikim's comment, this isn't that much about containers, but more ignoring the property/nesting. We could do, something like:
which would be equivalent to
This semantically meaningless nesting is a common pattern in JSON. See for instance |
That sums it up well I think, @lanthaler. Perhaps though, lingering on the container concept, and specifically to save us from a new keyword, it could be: {
"@context": {
"@vocab": "http://example/vocab#",
"group1": "@container"
}, seeing that a "nest" is a kind of container, in a loose sense. Not sure about the clarity, that might be quite some overloading of meaning. Worth to consider though. |
I don't know that we want to reuse In other words, I can see people wanting to be specific about particular structure-only terms -- but they may also want a catch all for this. With that in mind, I think it may be odd to say that every undefined term is a |
The downside is that Alternatively, Creating some kind of inverse container would allow existing practice for If the group doesn't think that round-triping is important anymore, or that preserving |
I've completed an implementation in my library. It uses the I'll work on a PR on top #449. The following is a description which can go in a "Transparent Nesting" section in the Syntax document: Many JSON APIs separate properties from their entities using an intermediate object. For example, a set of possible labels may be grouped under a common property:
In this case, the
Similarly, properties may be marked with "@container": "@nested", to cause them to be nested. Note that the
In this way, nesting survives round-tripping through expansion, and framed output can include nested properties. |
My main (possibly overly frugal) concern was to avoid a new keyword. Roundtripping in some way is valuable, and I think your solution @gkellogg is better. However, I think the Example: {
"@context": {
"skos": "http://www.w3.org/2004/02/skos/core#",
"labels": "@nest",
"linking": "@nest",
"main_label": {"@id": "skos:prefLabel", "@nest": "labels"},
"other_label": {"@id": "skos:altLabel", "@nest": "labels"},
"homepage": {"@id":"http://schema.org/description", "@type":"@id", "@nest": "linking"}
},
"@id":"http://example.org/myresource",
"labels": {
"main_label": "This is the main label for my resource",
"other_label": "This is the other label"
},
"linking": {
"homepage": "http://example.org"
}
} Actually, that way it wouldn't even be necessary to declare the nests themselves, other than naming them in the terms belonging to them. But omitting that might make the feature more obscure. (Note that in theory, I would recommend against "nests" within instance data for this very reason. I'd say that belonging to a nest (group/section/category) in this way is a property of a term (e.g. "prefLabel is part of the 'labels' nest"). That "really" belongs to information at the vocabulary level. Using it at the instance data level sort of conflates data with presentation. But in practice I can see how this would not be considered easy enough, and we know that this design does exist in the wild. So I'm not really against it in practice.) |
I'm just thinking, wouldn't |
@asbjornu That sounds more like the already existing mechanism of setting a term to This use case is about grouping of real terms, and I'm not sure And in my suggested change, it also works in conjunction with the desire to allow round-tripping (actually, for directing the compaction algorithm to perform the grouping), by connecting the term members to each nest. |
I think we used the keyword |
@niklasl: I see, thanks for explaining. I just think |
Naming is, of course, one of the two hardest problems in computer science 😄.
As for tying it to the
In this sense That said, using Perhaps we can get more feedback on two things: the choice of the keyword ( Not surprisingly, I prefer the way I stated it. |
Looking at some alternatives for
Please indicate your preference(s). cc/ @dbooth-boston |
Also, while we're giving preferences. Please choose between:
|
Looking at the commit message: "This adds a I also nominate |
@nest makes the most sense to me. Preference to term property over container. |
Some other possible names: |
Please don't tag random people. |
My preference is `@keyword` |
@dbooth-boston I added those other than |
When considering names, consider that the term is used for both expansion and compaction. When compacting, it will introduce the layering; it's removed on compacting. |
Text related to this feature that I can imagine making sense to people:
|
@dlongley, in your proposed text above, I suggest: s/mean anything/appear/ Also, one other name to consider: |
How about @structure? |
(Sorry for tagging by mistake. I used escape before the at sign which was incorrect.) |
I think it is important to convey that these terms are not properties, per se (in the RDF sense, nor in the JSON-LD node sense, I believe). They directly represent a nested structure (somewhat akin to So I prefer (Having thought about it, I strongly think we should keep having them declared explicitly (as @gkellogg also does in the implementation). Otherwise one has to inspect a context at depth to find out if a term represents a nest, instead of just looking up the term to find out what it means.) |
Btw, could there be some other JSON structures in addition to "nesting/collapsing" that do not have a semantic meaning in RDF? Coming back to containers: isn't this the case with index containers too that the keys do not have a semantic meaning in RDF? Therefore, index and nesting are quite close to each others... Would it make any sense to consider nesting to be a specisl case of indexing where the subject of the indexed (JSON/RDF) object is the same as the parent object? Container=nestindex or |
Yes, and I'd prefer that this is the case. Can we extend @index with some decoration that asserts what the @id should be set to?
This fits into the |
Currently, if a property does not expand to an IRI or BNode, it, and it's contents are ignored, so that is a way of having content with no semantic meaning.
The
This is pretty much what the @msporny That mechanism looks pretty confusing to me, and I think we're otherwise settling on PR #453 and just trying to fix terminology. I'd really hate to go back to the drawing board at this time, as this mechanism just works and is nicely orthogonal to So far, I'm seeing support for the following:
I propose that we accept PR #453 as is using |
At the TPAC discussion on JSON-LD 1.1, there were some complaints on the name of the |
Deferred to WG due to https://json-ld.org/minutes/2018-04-10/#resolution-3. |
Closed in favor of w3c/json-ld-syntax#3 |
Thanks for the great work with JSON-LD! However, when trying to use JSON-LD for to present data in the company I'm working in, I noticed the following missing feature:
FEATURE PROPOSAL: ABILITY TO DEFINE ANY KEY AS AN INDEX KEY
In addition to JSON-LD's existing index container structure, I propose that any key under a JSON-LD node could be defined as a index key.
This would help clustering data under a node into coder friendly logical groups without messing up the Linked Data interpretation with e.g. blank nodes. I encountered the need for this feature at our company where our problem is that the amount of attributes a single JSON-LD node can have can potentially be quite many, say, tens or hundreds of attributes.
As far as I know, this can not be currently done with JSON-LD without 1) ending up with blank nodes or 2) the need to create a deeper JSON structure by using a separate index term (using "@container":"@index") which then contains the data underneath.
In addition, if a single key could be defined as a index term, this would make it more flexible to attach the JSON-LD Linked Data interpretation to even a wider amount of existing JSON data, without having to change the structure of such data (and without ending up with e.g. lots of blank nodes).
DEFINING AN INDIVIDUAL INDEX KEY IN @context
The "@context" definition could be done e.g. using the existing reserved keyword "@index" in the following way:
which should be interpreted in the following way: 1) the "indexkey" is an index key and should be skipped when traversing the JSON tree while doing the JSON-LD to RDF interpretation, 2) any data directly under the "indexkey" should be interpreted as data directly attached to the node of the indexkey (same RDF subject).
EXAMPLE
To give a full example, in the following a single key "labels" is defined as an index index key to help grouping the data into coder friendly logical groups without messing up the Linked Data interpretation):
This example JSON-LD should generate the following RDF triplets:
The text was updated successfully, but these errors were encountered: