Comments (3)
I have an idea for a future version of JSON-LD Framing.
As a web developer, I would like to receive a JSON document from i.e. a simple API, add a @context
to it, and perform JSON-LD operations. This light approach has been a big selling point to me for using JSON-LD.
A common response from such an API may include an "id" property as a number (as it is indexed in the source database as an integer), so after applying the @context
the document may look like this:
{
"@context": {
"@base": "http://starwars.com/",
"@vocab": "http://starwars.com/",
"id": "@id",
"type": "@type"
},
"id": 123,
"type": "Human",
"firstName": "Luke",
"lastName": "Skywalker"
}
The expansion step will generate an error:
Invalid JSON-LD syntax; "@id" value must a string.
This makes sense, but my intention in declaring the @base
was to form the IRI "http://starwars.com/123". I don't think this kind of type coercion is currently possible with JSON-LD.
The alternative would be a blank node with a custom ID property, which is less useful in certain situations.
I propose a framing solution that generates a new triple with the coerced XSD type and removes the original, so that when flattened, it becomes:
[
{
"@id": "http://starwars.com/123",
"@type": [
"http://starwars.com/Human"
],
"http://starwars.com/firstName": [
{
"@value": "Luke"
}
],
"http://starwars.com/lastName": [
{
"@value": "Skywalker"
}
]
}
]
As a starting point, I suggest adding a term called @coerce
.
from json-ld-framing.
This would probably be in compaction/expansion rather than framing. It is somewhat similar to the useNativeTypes
option for fromRdf.
Itβs a common idiom in JSON, so itβs worthy of future consideration.
from json-ld-framing.
Thanks! I opened a new issue in the other repo.
If that's right, this can be closed.
from json-ld-framing.
Related Issues (20)
- Should tests for `@embed`: `@last` be restricted to JSON-LD 1.0? HOT 4
- Framing and Arrays HOT 4
- Ex. 41 Playground doesn't contain `@omitGraph: false` + playground does not apply `@omitGraph` HOT 3
- Pattern Matching HOT 4
- Can frames produce id maps? HOT 2
- Possible typos HOT 2
- Use a property several time when framing HOT 1
- validation errors/warnings HOT 1
- Language map with global context HOT 1
- IANA profile should be `frame` not `framed` HOT 5
- how to use the `frame` and `framed` profiles? HOT 12
- Fix invalid WebIDL HOT 1
- Change "Lexicographical Order" (and related) to "Unicode code point order". HOT 1
- Possible bug with `@json` being treated as invalid `type` in frame HOT 24
- How to use specific value inside a frame to filter out credentials those do not contain that value
- Framing on nested graphs
- Add test for `@graph` keyword aliasing
- more JSON-LD framed examples for performance testing
- Framing to a default language for the entire doc HOT 5
- test GH action
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-ld-framing.