-
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
JSON-LD 1.1 Feature Request: support @values for describing multidimensional containers (list of lists) #397
Comments
As JSON-LD is a released Recommendation, the only way to resolve such an issue is through an update to the specification. This requires chartering a new Working Group with the goal to update the JSON-LD specs (along with possibly other related goals). Such working group's aren't chartered easily. There are a number of other similar features (new requirements) that we're also tracking in this repository, along with a goal of sometime publishing JSON-LD Framing. One issue that this request, and some others faces, is the round-trip nature of JSON-LD Compaction/Expansion. Expanding the example you have above would result in something like the following: [{
"@id": "http://example.org/LineString1",
"http://geojson.org/vocab#coordinates": [{
"@list": [{
"@type": ["http://geojson.org/vocab#Coordinate"],
"http://geojson.org/vocab#longitude":
[{"@value": "3.105740547180175E0", "@type": "http://www.w3.org/2001/XMLSchema#double"}],
"http://geojson.org/vocab#latitude":
[{"@value": "5.106421622994348E1", "@type": "http://www.w3.org/2001/XMLSchema#double"}]
}, {
"@type": ["http://geojson.org/vocab#Coordinate"],
"http://geojson.org/vocab#longitude":
[{"@value": "3.1056976318359375", "@type": "http://www.w3.org/2001/XMLSchema#double"}],
"http://geojson.org/vocab#latitude":
[{"@value": "51.063434090307574", "@type": "http://www.w3.org/2001/XMLSchema#double"}]
}]
}]
}] When compacting with this context, we'd expect to get back the original. As you can see, such features can make this quite difficult, but of course, not impossible. We could consider relaxing this requirement for certain features in the future. For now, the best way forward is to do as you suggest and get existing parsers to have a processing mode to support this (as well as other features). |
With everything @gkellogg just said in mind... another possibility would be to introduce a new {
"@context": {
"foo": "http://example.org/",
"coordinates": {
"@id": "foo:coordinates",
"@container": "@json"
}
},
"@id": "urn:test",
"coordinates": [[1,2],[3,4]]
}
This makes the data in the RDF form less accessible but allows for a much easier round trip to and from the JSON. |
@pietercolpaert So the idea is transform the list of list into a list of objects? Since the transformation that you exemplified is isomorphic to: {
"@context": {
"coordinates": {
"@id": "geojson:coordinates",
"@container" : "@list"
},
"coordinate": "geojson:Coordinate",
"longitude": "geo:longitude",
"latitude": "geo:latitude"
},
"@graph" : [{
"@id" : "ex:LineString1",
"coordinates" : [
{
"@type": "coordinate",
"longitude": 3.1057405471801753,
"latitude": 51.064216229943476
},
{
"@type": "coordinate",
"longitude": 3.1056976318359375,
"latitude": 51.063434090307574
}
]
}]
} In this way, you cannot apply the same idea for "@context": {
"collection": {
"@id": "ex:list",
"@container" : "@list",
"@values": {
"@type" : "ex:innerList",
"@container" : "@set",
"@values" : {"@type" : "ex:elementType", "@id":"ex:element"}
}
}
} Which cannot be expanded in the same way you exemplified. Your design only works for a list of lists, where the number of elements in the inner list is fixed and know in advance. No even sets can work since you cannot map correctly which is the latitude and which is the longitude if the order doesn't matters. (so i would guess that you meant the inner container to be In GeoJSON-LD this means that in the proposed way you cannot represent Polygons (with holes), MultiLineString, and MultiPolygons. |
Is it a strict requirement that GeoJSON-LD looks exactly the same as GeoJSON (modulo the @context property perhaps)? If so, why? What speaks against a standardized (and almost trivial) pre-processor for converting application/vnd.geo+json to application/ld+json? |
@lanthaler it is for me, yes. I want to use JSON-LD to improve the quality of existing GeoJSON data without giving up benefits of ordinary GeoJSON like maps on GitHub. |
Summarizing the aboveWe now have 3 suggested solutions:
Personal replies@jasnell Adding a "this is a json string" will need custom parsers to get sense out of the data that is in the JSON string. I'm afraid that this will lead to JSON-LD dialects and forks of the parser @dinizime Indeed: my suggested solution is not usable. Could we however find a solution that is? When taking @gkellogg's comment into account, I believe that indeed, just extending JSON-LD to any kind of JSON object might make the spec too complex. @sgillies I think @lanthaler meant that GeoJSON-LD could extend JSON-LD with its own Personal preferenceFrom a purist perspective, option 2 would be perfect. Yet it will take long to find the nicest solution which will satisfy everyone. From a pragmatic point of view, I think going for option 3 is the best option without doing any harm: option 2 can still be implemented in the long run. In meantime, @sgillies has already done a proposal to fix it this way: geojson/geojson-ld#37. |
Yeah, I have been wondering about this as well. The current implementation is quite cumbersome. Funny how I just made up an implementation and we arrived at the same solution. |
Quite complicated use case that makes round-tripping impossible, and many questions for multi-dimensional data. Perhaps better preserved using a JSON Literal, and separate rules run in the RDF space. |
See http://geojson.org/geojson-ld/ for a motivation for use in GeoJSON. |
See thread on [email protected] for a discussion starting with geojson needs. |
Deferred to WG due to https://json-ld.org/minutes/2018-04-10/#resolution-3. |
Closed in favor of w3c/json-ld-syntax#7. |
For anyone following this, current plan is to close this as "won't fix", so please give any feedback about this here: w3c/json-ld-syntax#7 |
Problem description
Many JSON specs existed before JSON-LD. A couple of these specs may not be compatible with JSON-LD as they contain multidimensional containers, such as GeoJSON.
Example of a multidimensional array:
This issue is a result from the discussion on the GeoJSON-LD repository: geojson/geojson-ld#32. If this issue will not get resolved, the GeoJSON-LD community would suggest creating custom JSON-LD parsers for JSON-LD dialects. This situation would be far from desirable.
Suggested solution
Introduce a new
@values
keyword, which can be used to describe the values of a@set
or a@list
container in more detail.When an array is given in the
@values
, then the precise amount of objects within this array corresponds with the array in the graph in this order.When an object is given in the
@values
, each value of the array in the graph is mapped according to this template.Example
Would transform to (and vice versa):
The text was updated successfully, but these errors were encountered: