json-ld.org icon indicating copy to clipboard operation
json-ld.org copied to clipboard

Parse YAML workaround. See #875.

Open ioggstream opened this issue 2 months ago • 3 comments

This PR

  • modify the parser to accept YAML instead of JSON

Notes

I tried to bundle the editor with npm run build:editor, but it does not seem to work on my PC, while just modifying the .js works.

ioggstream avatar Nov 04 '25 16:11 ioggstream

  • Certainly need to update the source for any such change. The generated code will be overwritten.
  • This is probably a more involved discussion. The playground code doesn't yet handle the YAML-LD spec. I'm guessing you at least want the minimal feature of parsing JSON-LD that was serialized as YAML. That's fine, but I think the playground should also be able to have a mode that only accepts valid JSON. Which probably means the parsing type needs to be a choice. I'm not sure how that should all work.

davidlehn avatar Nov 05 '25 16:11 davidlehn

I tried to bundle the editor with npm run build:editor, but it does not seem to work on my PC, while just modifying the .js works.

@ioggstream what bundling error did you experience? I'd like to make sure that's fixed.

I like the intent of this PR! I'll see about getting it in via a pre-built code change and probably also some UX affordances to make sure it's clear one could do either.

However, I agree with @davidlehn that we also need to have an eye on any requirements/tweaks introduced to "just YAML" by the YAML-LD spec. @anatoly-scherbakov can probably advise where it may go beyond a simple YAML.parse() operation. At minimum, I think we'd need to throw errors if/when more advanced YAML features appear in the document.

Definitely something we want to see happen, though!

BigBlueHat avatar Nov 12 '25 15:11 BigBlueHat

The YAML-LD spec does not forbid advanced YAML features, it just warns that documents with such features will be not round-trippable. Which is fair. Other than that users can write whatever valid YAML they wish.

anatoly-scherbakov avatar Nov 12 '25 15:11 anatoly-scherbakov