Jump to content
Sign in to follow this  
jairgza

Yaml to json simple convert

Recommended Posts

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

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 by David Heffernan

Share this post


Link to post

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
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

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

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
Sign in to follow this  

×