-
Notifications
You must be signed in to change notification settings - Fork 8
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
Round-trip safe json-ld -> yaml-ld -> json-ld #8
Comments
What do you meant by round-trip safety? Given a YAML-LD document Y1 the YAML-LD specification will define a transformation to a corresponding JSON-LD document J1. The transformation will unlikely be bijective so another documents Y2 may exist being transformed to J1 as well. I suppose transformation from JSON-LD to YAML-LD is out of the scope of YAML-LD specification anyway, isn't it? J1 could be expressed in Y1, Y2... as you like as long as these transform to J1. There may also be JSON-LD features not supported by YAML-LD (to be discussed) because they are semantically irrelevant, should these be preserved as well? As far as I understand round-trip safety, the only way to formally tackle it is to define canonical document forms. |
If it's any different than Canonical forms require the use of a canonicalization algorithm, as is defined for JSON-LD in the spec. I'm not aware of a similar algorithm for YAML, but it could likely use the same logic. I think the way to look at round-tripping is that parsing YAML-LD or JSON-LD documents to the internal representation should produce equivalent internal representations, which leaves out canonical serialized forms, document ordering (except as required), and keyword transformations. |
Not a YAML expert here, but since YAML data types are wider than json ones, I think we should anyway state that yaml-ld MUST extend json-ld features. Agree with @gkellogg :
|
If to use the
(idea © #9) — then, after a naive conversion to YAML-LD and then back to JSON-LD we will see
which is not even a valid JSON-LD because
Knowing that, we can implement this as an edge case where |
This was discussed during today's call: https://json-ld.org/minutes/2022-06-22/. |
@ioggstream Round-trippability can be understood at different levels:
Absolutely.
There's no question it's the most important base case, and we should agree that once and for all, and move on to discussing YAML extensions, options and fringe cases, because that's where the meat is. I.e., the default case is trivial and well-understood. @gkellogg, does that allay your concerns, or am I under-estimating the default case?
Agree! Does JSON-LD define such internal representation, where is it, @nichtich your thoughts on bijectivity etc are relevant
In the contrary, it's part of the "default case" thus very important.
That's not right for two reasons: 1: if we accept #51, one can use it to effect uniform keyword aliasing in YAML like this: "@context":
$id: @id
$type: @type
$value: @value
# etc This will result in JSON like this "@context": {
"$id": "@id",
"$type": "@type",
"$value": "@value"
} That's not the degenerate form you've shown. 2: Where do you read "keywords cannot be overridden"?
|
That's pretty much my view.
JSON-LD defines the internal representation. While it could potentially be extended (e.g., different types of numbers), we'd need to carefully justify doing so.
I would not say so. My view is the round-tripping means that there is no semantic loss in turning JSON-LD -> YAML-LD -> JSON-LD or visa-versa. Trying to get back to exact syntactic forms is a needless complication. Having both go through RDF would also be acceptable, and generating the results will of necessity involve applying contexts (compact form) or frames (framed form). It may be possible to reproduce the embedding structure without the use of framing in either direction that doesn't involve flattening or toRDF, but this is a nice-to-have artifact, not a requirement.
Yes. But, we can go overboard with trying to encourage the use of
There are actually reasons for doing things like this, e.g., |
This issue was discussed in today's meeting. |
As an
<user with json-ld files>
… WHOI want to
<convert them to yaml-ld>
… WHATSo that
<they are round-trip safe>
… WHYNote
imho any other behavior hinders interoperability
The text was updated successfully, but these errors were encountered: