YAML support?

Just starting out? Need help? Post your questions and find answers here.
highend
Enthusiast
Enthusiast
Posts: 169
Joined: Tue Jun 17, 2014 4:49 pm

YAML support?

Post 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, ...?
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: YAML support?

Post by Rings »

I'll add my name here, has anyone already done something along these lines?
At least read it?
SPAMINATOR NR.1
User avatar
STARGÅTE
Addict
Addict
Posts: 2235
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: YAML support?

Post by STARGÅTE »

I've been looking for it too. I'll try write a module this weekend and get back here.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Quin
Addict
Addict
Posts: 1133
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: YAML support?

Post 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
miso
Enthusiast
Enthusiast
Posts: 467
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: YAML support?

Post by miso »

Just for the note, I'd also pick up such a module.
Fred
Administrator
Administrator
Posts: 18244
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: YAML support?

Post by Fred »

There is a C lib for this if you can use it as base for your module: https://github.com/yaml/libyaml
User avatar
STARGÅTE
Addict
Addict
Posts: 2235
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: YAML support?

Post 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.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
miso
Enthusiast
Enthusiast
Posts: 467
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: YAML support?

Post by miso »

For me it's secondary. I prefer the former, but still would be happy with the latter.
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: YAML support?

Post 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?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
miso
Enthusiast
Enthusiast
Posts: 467
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: YAML support?

Post 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.)
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: YAML support?

Post 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.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
miso
Enthusiast
Enthusiast
Posts: 467
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: YAML support?

Post 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.
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: YAML support?

Post 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.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Post Reply