Jump to content

How to update yaml files?


ur
 Share

Recommended Posts

There are few yaml files which I need to update the entries by going through the portions of it based on its heading.

One option I thought is to keep place holders but that same entry there in multiple sections, need to choose based on the section head in yaml.

Is there any UDF already available to handle yaml files?

Didn't find any in the search results.

Can anyone please suggest.

Link to comment
Share on other sites

  • Developers

I do not see any relation with YAML files and JSON other then when a field value has a JSON content. 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

That is a request for a YAML UDF where somebody points to the JSON UDF as base to start with but there is nobody that did the actual work!

Nice challenge for you maybe? ;) 
... or if the change is "simple" you can use regex logic.

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 months later...

In the past few weeks I have been searching up and down, left and right for a way to implement yaml in a upcoming program of mine. Of course I can use JSON and be done with it, but the beauty of simplicity of YAML was always in my mind. For some reason I cannot just let it go.

There are tons of resources about YAML. A lot of examples. Python, Javascript, Java, C++, PHP ... They all support it. It gives me a lot of doubts why no one here can make a UDF about it.

That's until I start to make an UDF myself, that I started to understand why. YAML looks easy, but it's a nightmare for programmers. There are many many things need to consider. Even a trimmed down limited implementation of YAML is pretty tough.

I don't want to go through all the failures I suffered chasing this, but now I finally found quite a possible solution for this:

https://github.com/mikefarah/yq

According to them, "yq is a portable command-line YAML processor". You can pipe the YAML string in and pipe the decoded JSON out. Or you can ask it to load a file.

You can use it to output properties, JSON, or CSV / TSV, and you can update the YAML file with comments intact.

The release file is not big. X64 is 8mb and x86 is 7.5mb. I wish there are an easy DLL file that can do the same thing, but after all the searches, I found none. When other languages enjoy built-in support of YAML, I think AutoIt, for now, has to go with the "yq -> JSON -> Objects" route.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...