jairgza 0 Posted February 1, 2021 Hi all I have some new yaml files for settings that I need to read, all my apps use json parsers (TDocVariantData or JsonDataObjects) and I was looking an easy way to just convert yaml text to json text and continue using my already implemented and familiar json parsers. I found one yaml parsers but it does not convert to json. Any of you know some library or how to do this ? thanks Share this post Link to post
David Heffernan 2345 Posted February 1, 2021 (edited) Trivial to do in Python. Read the YAML in, then dump to JSON. I'm assuming that this is a one time conversion. Because otherwise you'd use a YAML parser directly and wouldn't convert to JSON. Edited February 1, 2021 by David Heffernan Share this post Link to post
jairgza 0 Posted February 2, 2021 Yes, as you say, its only one time read, I'm not going to generate any yaml from programs. I was looking for something already usable in delphi, but I think im going to use grijjy neslib to make my own converter 🙂 Share this post Link to post
David Heffernan 2345 Posted February 2, 2021 1 hour ago, jairgza said: Yes, as you say, its only one time read, I'm not going to generate any yaml from programs. I was looking for something already usable in delphi, but I think im going to use grijjy neslib to make my own converter 🙂 It's really way easier in Python. Essentially a two liner, one to parse, and one to dump. That's how I'd do a one time conversion. Share this post Link to post
jairgza 0 Posted February 2, 2021 My bad, I think I didn't explain myself sorry, it's not a one time conversion, but every time the app runs needs to read a yaml file and translate into json so all the current (large) code can be used without modification. The yaml files are edited manually by users. cheers Share this post Link to post
David Heffernan 2345 Posted February 2, 2021 OK. In that case I definitely recommend the neslib parser. I myself use libyaml2 but neslib is good. Share this post Link to post