Jump to content
Vincent Parrett

New YAML Parser Library - VSoft.YAML

Recommended Posts

Hi All

 

I have released a new YAML Parser/Emitter library for Delphi XE2 or later. It is pure delphi code, tested with Win32 and Win64 but it should work for other platforms too (no winapi dependencies). 

 

  • Supports YAML 1.1 (partially) & 1.2 
  • JSONPath queries with filter expressions
  • Multiple Document streams.


https://github.com/VSoftTechnologies/VSoft.YAML
 

  • Like 11
  • Thanks 3

Share this post


Link to post

You are missing passing TFormatSettings to the StrTo... functions that you are calling - that makes it fail on systems that use a comma as a decimal separator, for example.

  • Like 2

Share this post


Link to post

With a few missing TFormatSettings fix - it now works on different locales - and is tested on Linux (2 tests failing due to file path issues in the tests). It should work on OSX and mobile but I haven't tested that. 

  • Like 1
  • Thanks 1

Share this post


Link to post

On initial install this looks really good. I have been using Neslib.Yaml up till now but look forward to seeing how this compares. The backwards compatibility is a plus - Neslib.Yaml requires Delphi 10.4 or higher.

Share this post


Link to post
11 hours ago, mvanrijnen said:

Nice work,  maybe a good base for upgrading our  config files to YAML, 

Thanks. What format are you using for your config files now? If it's JSON, the parser should be able to load them - since YAML 1.2 is a superset of JSON - I added some unit tests and fixed one small bug with whitespace handling today.

Share this post


Link to post

RealThinClient has very powerful TRtcInfo, it is simply put magnificent, capable of many things, but few things in particular are most powerful, namely the ability to read from XML, XML-RPC, JSON and its own binary compacted format also the ability write to any.

https://github.com/teppicom/RealThinClient-SDK/blob/develop/src/Lib/rtcInfo.pas#L4073-L4146

 

 

YAML is beauty, and having the ability to convert to/from JSON would be fantastic feature, so this might be feature suggestion.

Share this post


Link to post

Converting to JSON would be case of adding a new writer class that can write the yaml classes out - wouldn't be difficult. I will look at it when I have time.

  • Like 2

Share this post


Link to post
7 hours ago, Vincent Parrett said:

Thanks. What format are you using for your config files now? If it's JSON, the parser should be able to load them - since YAML 1.2 is a superset of JSON - I added some unit tests and fixed one small bug with whitespace handling today.

mostly good old init style like files, one service an xml as config file, but most ini style like. 

we got our own config readers for this wich works with attribute decorating, busy with some new things, gonna pick this up with yaml. 

 

It's always a bit of puzzle with "nesting" with the ini style like configs. 

 

 

Edited by mvanrijnen

Share this post


Link to post

Nice job.  It would be great, if there was also a serialization layer.  For instance you have a config object and you save it to a YAML file with a single command.  You then deserialize it and use it directly without having to query the YAML document.  See for instance pyscripter/toml-delphi: Toml parser and writer for Pascal and Delphi.

Edited by pyscripter

Share this post


Link to post
1 minute ago, pyscripter said:

It would be great, if there was also a serialization layer.

I considered it - I did look at what you did with your toml parser - but I have a requirement to work with XE2+ and the system.json unit has various bugs that I did not want to fight with each version of delphi I support. 

Share this post


Link to post
6 minutes ago, Vincent Parrett said:

but I have a requirement to work with XE2+ and the system.json unit has various bugs

I understand.  Json serialization (System.JSON.Serializer) became reliable only with Delphi 11 and later.  I think it was introduced in Delphi 10.4.

Edited by pyscripter

Share this post


Link to post
20 hours ago, Kas Ob. said:

AML is beauty, and having the ability to convert to/from JSON would be fantastic feature, so this might be feature suggestion.

Done. Adding JSON writing was pretty trivial. 

  • Like 3

Share this post


Link to post
3 hours ago, Vincent Parrett said:

Done. Adding JSON writing was pretty trivial. 

With JSON writing/reading, adding serialization for Delphi 10.4+ should be trivial.

Share this post


Link to post
3 hours ago, Vincent Parrett said:

Done. Adding JSON writing was pretty trivial. 

Nice !

 

Not seeing reader or i am missing something ?

With reader from JSON, this library will become a must-have tool simplifying JSON debug handling, YAML is human reading friendly, so can be used where JSON usually used also replacing INI and config files.

 

Share this post


Link to post
7 minutes ago, Kas Ob. said:

Not seeing reader or i am missing something ?

You don't need anything special to read json - just call TYAML.LoadFromXXX  

  • Like 1

Share this post


Link to post
16 minutes ago, pyscripter said:

With JSON writing/reading, adding serialization for Delphi 10.4+ should be trivial.

I would probably do that as a separate library - it's certainly doable.

  • Like 1

Share this post


Link to post
33 minutes ago, Vincent Parrett said:

You don't need anything special to read json - just call TYAML.LoadFromXXX  

Yes i was hasty to not consider the generic way to load, nice!

 

image.thumb.png.152ebaf94e638bbaf5c55dfea78edddf.png

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×