json-ld / yaml-ld

CG specification for YAML-LD and UCR

Home Page:https://json-ld.github.io/yaml-ld/spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YAML presentation ("cosmetic") controls

VladimirAlexiev opened this issue · comments

As an information architect.
When serializing YAML.
I want control over all YAML presentation ("cosmetic") features.
So that I can obtain a YAML representation that is most readable and usable for my case.

What "cosmetic" features do I mean:

  • optional header --- and footer ...
  • Number of spaces used to indent
  • Use of flow-style vs block-style for particular pieces of YAML
  • Ordering of keys
  • Alias names
  • Formatting of text blocks
  • String quoting
  • Use of escapes and code points in strings
  • Serialization of booleans
  • etc etc

How to list all controllable features systematically?

Here are the options of some serializers:

Most of these are for Perl, could you please add links to serializers in other languages?

Maybe we should also turn to linters. https://megalinter.github.io/latest/descriptors/yaml/ can use 3 YAML linters:

Finally, this specifically aims to fix presentation, but currently has a somewhat limited set of options

@VladimirAlexiev do you think we should define a recommended serialization for YAML-LD, or just to define a linter configuration for this repo (:+1: ) ?

I think YAML serialization configuration should be delegated to YAML and implementations, because they will improve over time.

An interesting caveat is instead the one related to multiple documents in the same stream, e.g.

---
a: 1
...
---
a: 2
...

@ioggstream We should definitely use a consistent style of all our examples, so we need a linter configuration for this repo.

serialization configuration should be delegated to YAML and implementations,

Maybe. However:

  • The JSON-LD Context defines a lot about the form of serialized JSON: in fact all information aspects, but no presentation aspects.
  • If the primary goal of YAML-LD is readability, why shouldn't presentation aspects be part of a "YAML-LD Context" (#44)?

I think adopting a consistent style for our examples is important, but 👎 on putting anything about a required style in the spec itself. In any case, that should be a YAML concern, not a YAML-LD concern.

I'm struggling to grok exactly what is proposed here, but I interpret this as a call for supporting the "non round trip-able to JSON features"... which I am in favor of... just we need to start using unique names for both cases.

I suggest we just start considering them different media types...

application/ld+yaml vs application/ld+json+yaml.

One is JSON-LD round trip-able... the other is not.

application/ld+yaml should allow for cosmetic features... +1 to the proposal.

@OR13 I will vote after the testcases are written :) These days I'm struggling even with very simple issues like extending fragment identification to YAML streams ietf-wg-httpapi/mediatypes#55 since I just discovered that future versions of YAML might consider that docs in a stream are not independent :P

I agree with @gkellogg and @ioggstream that the spec shouldn't claim any required style. But it can point to a linter configuration as a useful resource.

I agree with @gkellogg and @ioggstream that the spec shouldn't claim any required style. But it can point to a linter configuration as a useful resource.

Any such mechanism should probably work for JSON as well. But, I'm not aware of any such convention, or how we might signal that, other than through API extensions.

Discussed at TPAC F2F and resolved to close as out-of-scope.

@gkellogg

such mechanism should probably work for JSON as well

YAML has a lot more formatting options, eg to limit display line length of strings.
In JSON you can only vary the indentation and newlines.