-
Notifications
You must be signed in to change notification settings - Fork 12
Resolve remaining IPLD questions #4
Comments
In IRC we found that it was possible to put in the context a If we want that on the top level, though, I don't think we can have a We must then arrange for the Node type to contain the link to the context separated from the data. |
not by a ton. we could benchmark this. i expect a constant increase, not orders of magnitude.
Why cant we grab them like this: https://github.com/ipfs/go-ipld/blob/master/ipld.go#L122-L158 ? Are you worried about people remapping things to be |
You can't be sure what name has a type unless you parse the context. There are multiple issues there:
There are other issues about your flattened map, it looses all the semantic from JSON-LD in my opinion, for few reasons:
I think we should choose: If we want to be JSON-LD compatoble, we should't impose too much restrictions. And a JSON-LD author will find it difficult to find a way to describe a document with all these restrictions. The other solution is to support JSON-LD in full, but this is not as easy as parsing JSON. We should recognize that. Or else, we should find another way to be compatible, or define the level of compatibility we want. But please don't call JSON-LD what it is merely a subset. |
Perhaps we could imagine to require a flattened JSON-LD when we want to store it: http://www.w3.org/TR/json-ld/#flattened-document-form From the spec:
This is great because we write the object once, but read it many times. The issue is that the original document format is lost. Your document must be fully compatible with JSON-LD and non compatible parts would be lost. |
Snips from the channel:
|
More notes@diasdavid and I resolved that the main feature we want/need from JSON-LD at the moment is just the All we need to practically implement the aliasing is a module that provides aliasing var expand = require('ipld-expand')
var jsonObjEmbedded = {
"@context": [
schema["@context"]
]
"foo": {
"mlink": "<hash>"
}
}
console.log(expand(jsonObj))
// {
// "foo": {
// "/ipfs/<hash-of-mlink>/mlink": "<hash>"
// }
// }
// now suppose we have a separate context
var schema = {
"@context": {
"mlink": "/ipfs/<hash-of-mlink>/mlink"
}
}
// expand takes the object to expand, and a map of "url : contextObj".
// (so expand doesnt retrieve anything, it's already retrieved.)
expand({
"@context": "/ipfs/aaaaa/ipld",
"foo": { "mlink": "<hash>" }
}, {
"/ipfs/aaaaa/ipld": schema,
"/ipfs/bbbbb/bbb": {...},
"/ipfs/cccccc/ccc": {...}
})
// another option is to do it with an object that supports "get(url)". so
// it could be backed by a simple map (like here), or by http or ipfs proper
expand({
"@context": "/ipfs/aaaaa/ipld",
"foo": { "mlink": "<hash>" }
}, getContext)
// whete getContext is a function that could make requests, like:
// getContext("/ipfs/aaaaa/ipld") -> schema
// this is obviously slow and brittle in the HTTP case, but may be
// fine + robust in the IPFS case. |
I'll try to summarize what we said on IRC @jbenet ? We start from the following representation:
The problem is that we have to know which keys to expand to type URI (when we declare LD context) and which keys are filenames and must no be expanded. JSON-LD can declare values using We could imagine this structure in JSON-LD, but it has an extra level of indirection:
If we don't want to have the level of indirection, we depart from JSON-LD (which is not a problem if we can convert back to JSON-LD). The other problem is that we have a collision problem between filenames and @... directives. The proposed solution is to escape the @ character in keys:
When compacted it would lead to:
This is nice because this is almost JSON-LD object already. With directives stripped for JSON compatibility, it would transform to:
( Some extracts:
about escaping:
@jbenet you're ok with this ? For me the escaping is a very good solution, the only question left is about flattening. When you transform We're very close to compatibility with JSON (via escaping) and JSON-LD (via directives and flattening operation). |
thanks @mildred! all lgtm.
good questions. not sure yet. not sure whether we should store flattened by default-- user may want to preserve data structure. but we can flatten for our purposes. |
A fresh day, fresh ideas:
A unixfs entry as encoded by IPLD would appear like this:
With this, IPFS makes some simple assumptions. Easy flattening algorithm. The meaning of the We can also, after a translation step feed this to any JSON-LD consumer that would be quite happy to understand this in a LD context We can also strop the @ directives and give it unescaped to any JSON consumer @jbenet does it still correspond to what you want. How do you stop recursion, |
@mildred and i discussed where IPLD should go and what to do with the JSON-LD trickiness encountered. We should finish resolving what the plan is and document it here.
The text was updated successfully, but these errors were encountered: