Page 1 of 1

YAML support?

Posted: Sat Jul 22, 2017 9:50 am
by highend
Hi,

ok, there is JSON but even in it's "pretty" version
I find it hard to read / hard to skim quickly over it's content.

Has anyone ever written a module for PB to support YAML (http://www.yaml.org/)
that supports writing to / reading from a file, set and get keys, values, ...?

Re: YAML support?

Posted: Thu Dec 05, 2024 1:15 pm
by Rings
I'll add my name here, has anyone already done something along these lines?
At least read it?

Re: YAML support?

Posted: Fri Dec 06, 2024 7:14 pm
by STARGÅTE
I've been looking for it too. I'll try write a module this weekend and get back here.

Re: YAML support?

Posted: Fri Dec 06, 2024 8:06 pm
by Quin
STARGÅTE wrote: Fri Dec 06, 2024 7:14 pm I've been looking for it too. I'll try write a module this weekend and get back here.
You're definitely not the only interested one, I'd pick up a module if someone wrote it for sure :D

Re: YAML support?

Posted: Fri Dec 06, 2024 8:12 pm
by miso
Just for the note, I'd also pick up such a module.

Re: YAML support?

Posted: Sat Dec 07, 2024 11:51 am
by Fred
There is a C lib for this if you can use it as base for your module: https://github.com/yaml/libyaml

Re: YAML support?

Posted: Sun Dec 08, 2024 2:29 pm
by STARGÅTE
Thanks Fred.
However, while reading the full documentation of YAML, I realized that YAML has a much more complex specification than JSON or XML. :oops:
So, that will take some time ^^

@All:
I think I would avoid the use of the RegularExpression lib, to keep the module free of the PCRE Lizenz.
The next question is whether the module should have the PureBasic syntax:

Code: Select all

#YAML = 1
ParseYAML(#YAML, "[1, 1.23, 1.23e-3]")
Debug GetYAMLDouble(GetYAMLElement(YAMLValue(#YAML), 0))
Or should it be based on a structure:

Code: Select all

Define YAML.YAML
ParseYAML(@YAML, "[1, 1.23, 1.23e-3]")
Debug YAML\NodeTree\Element(0)\Double
I would prefer the latter.

Re: YAML support?

Posted: Sun Dec 08, 2024 2:45 pm
by miso
For me it's secondary. I prefer the former, but still would be happy with the latter.

Re: YAML support?

Posted: Sun Dec 08, 2024 5:00 pm
by jacdelad
YAML has a lot of special cases and irregularities, so out of curiosity: where do you want to use it, why and what things does it do better than xml/json?

Re: YAML support?

Posted: Sun Dec 08, 2024 5:59 pm
by miso
YAML has a lot of special cases and irregularities
Now I started to feel a bit ashamed, I would not want to force anyone to do extra work for me.
why and what things does it do better than xml/json?
It's absolutely much more readable by a human. Good for config files, but for example OpenXcom Oxce is completely scripted trough using yml files.
I started to become fascinated with yaml when I saw that how straightforwardly was it organized. (that was the first time I met this format.)

Re: YAML support?

Posted: Sun Dec 08, 2024 6:10 pm
by jacdelad
I understand, but XML/json can be printed out to be human friendly readable too. You know, PrettyPrint. There are 22 variants for booleans alone in YAML and it isn't really widespread. Don't get me wrong, every addition to PureBasic is great. Like OK image format and such.

Re: YAML support?

Posted: Sun Dec 08, 2024 6:25 pm
by miso
@jacdelad
I know, and Yaml is not a must for me.
If someone creates a module for him/herself, and willing to share, I would apply. Thats all.
There are 22 variants for booleans alone in YAML
Well, I did not know that. I don't think that the files I was browsing used the full capabilities yaml has.

Re: YAML support?

Posted: Sun Dec 08, 2024 9:05 pm
by jacdelad
YAML was especially designed to be better readable to humans. That's why it has many varieties for expressing data. And flexibility always comes with the cost of complex algorithms/libraries.
However, some popular software uses yaml, like Kubernetes, which is used by professionals, so there must be a legit reason why to prefer it over XML.