Re: minimal YAML recommendations?
Ingy dot Net <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CAHJtQJ4EqWQkYfjO2tNE2ePo9MLMgV+u8A7fPH5ZhhFCz_6yHg@mail.gmail.com> |
Hi mofo,
Oren, I always consider the 3 main additions from JSON to be:
- Types (Tags)
- References (Anchor / Aliases)
- Keys (can be any node, not simply strings)
Also:
- Multiple documents per file/stream.
Those are all model changes. The major syntax changes are:
- Block form (no {} [])
- Quoting styles (esp NoQuotes)
- Comments
The YAML spec is a little over complicated but I started this wiki to
discuss making YAML 2.0, simply be a reduction of the current YAML:
https://github.com/yaml/YAML2/wiki#yaml-20-proposals
There are quite a few documents on the net that people base modern
implementations on taht should probably be removed. People end up all over
the place on default schema (typing of unquoted strings). eg the string
*Yes* being loaded as a boolean. http://yaml.org/type/bool.html is the
culprit. Sometime after we published this we agreed that by default only
(true false null) and unquoted numbers should be loaded as non-strings.
In YAML, any node can be loaded as almost any object. It all depends on the
"schema" being used. We've been bad at making a best practices document. In
general, people make implementations where the schema is at least agreed
upon within the Load/Dump functions of that particular framework. In a
better world:
- there would be a clear default schema
- all implementations would adhere to it by default
- we would have a schema language
- implementations would be schema aware and have the ability to
load/dump accordingly
In the Perl world there exists a YAML::Tiny, which is a
non-yaml-core-approved but heavily used and useful thing that is the spirit
of this topic. It's doc has a mini spec:
https://metacpan.org/pod/YAML::Tiny#YAML-TINY-SPECIFICATION
I started a parser generator project called Pegex that is easy to port to
any language that has regex support. The primary idea is to make grammars
that are really easy for people to read and maintain, and that create
parsers in 20 languages at once. Here's a Pegex grammar for JSON and also
JSONY (a JSON variant I helped create):
- https://github.com/ingydotnet/json-pgx/blob/master/json.pgx
- https://github.com/ingydotnet/jsony-pgx/blob/master/jsony.pgx
These grammars have released implementations. My unfinished goal is to do a
YAML grammar for Pegex, so at least we can have a set of implementations
based off the exact same document.
If you'd like to chat more, find me in #yaml on irc.freenode.net
Cheers, Ingy
-
On Thu, Jan 29, 2015 at 1:21 AM, Oren Ben-Kiki <[email protected]> wrote:
> JSON is a subset of YAML so a "JSON to YAML converter" is just "cp".
>
> There are two big additions to JSON in YAML: (1) Block formatting, and (2)
> Tags & references for controlling de-serialization.
>
> So there are several potential growth paths from JSON to YAML.
>
> You could use a JSON format + the minimal additions for the full YAMLdata
> model (e.g. { "foo": !bar "baz" }). This would be easy to parse since there
> would be no block formatting, and you'd get YAML's additional
> de-serialization features. There doesn't seem to be much call for that...
>
> Or, you could envision keeping the JSON data model and just adding YAML
> block formatting for greater human readability (not easy to parse as humans
> are quirky). You could argue that this is what most YAML files do in
> practice.
>
> Both of these would be YAML-compatible subsets between JSON and YAML. You
> could feed them to any YAML parser today.
>
> Or, you could embed the additional YAML data model into the JSON data
> model e.g. { "tag": "...", "anchor" = "...", "=": { ... the clean JSON
> object } }, { "reference": "..." }, etc.). This would be neither YAML nor
> JSON (well, it would parse in both, but the data model would require
> additional processing).
>
> I don't think anyone would be comfortable with blessing any one of these
> very different approaches as "the one true way".
>
> On Thu, Jan 29, 2015 at 10:18 AM, mofo syne <[email protected]> wrote:
>
>> There was a discussion on a stripped down YAML, and I think previously
>> the consensus was that there is no need for a separate standard for
>> "minimal YAML".
>>
>> Rather what was suggested is to simply make a document that extends the
>> current YAML, by suggestion what can be included or omitted from the
>> standard. ( At the very minimum, it should allow for conversion of JSON to
>> a valid yaml file).
>>
>> Has there been any documents released lately regarding this? I haven't
>> noticed any from the official http://www.yaml.org/ site. And the
>> projects links from that site is still all "full version of yaml" type.
>>
>> I see a few people trying to create a stripped down YAML, but until there
>> is an official "one way to write a minimal JSON to/from YAML parser", it
>> would be all over the place. At least for those who don't need the extra
>> feature of yaml.
>>
>> ,
>>
>> mofosyne
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming. The Go Parallel Website,
>> sponsored by Intel and developed in partnership with Slashdot Media, is
>> your
>> hub for all things parallel software development, from weekly thought
>> leadership blogs to news, videos, case studies, tutorials and more. Take a
>> look and join the conversation now. http://goparallel.sourceforge.net/
>> _______________________________________________
>> Yaml-core mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/yaml-core
>>
>>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
> your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Yaml-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/yaml-core
>
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core