How to remove whitespace around the = when converting from yaml to props and change the . to any desired character? #1297
-
I'm trying to convert a yaml file to properties file. Everything seems to work fine but I would like to make two modifications to the properties file.
Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Just curious. Why not to just change it before yq call? |
Beta Was this translation helpful? Give feedback.
-
The properties encoder I'm using automatically puts the space around the equals sign - and there is no way to control that. According to the properties spec however, this whitespace is ignored (https://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0204propertiesfileformat01.html). That said, you can use an expression to generate your own format, including the '_' instead of '.': yq '.. | select(tag != "!!map" and tag != "!!seq") |
( (path | join("_")) + "=" + .)
' input.yaml Explanation:
|
Beta Was this translation helpful? Give feedback.
The properties encoder I'm using automatically puts the space around the equals sign - and there is no way to control that. According to the properties spec however, this whitespace is ignored (https://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0204propertiesfileformat01.html).
That said, you can use an expression to generate your own format, including the '_' instead of '.':
Explanation:
.. | select(tag != "!!map" and tag != "!!seq")
find all the nodes that are scalars (not maps or arrays)( (path | join("_")) + "=" + .)
grab the path array of the node, join with "_", a…