You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When attempting to apply style="literal" to JSON string values in a YAML file using yq, the transformation unexpectedly affects all string values, not just the targeted JSON strings, even when using select() to distinguish between JSON and non-JSON values.
This behavior makes it difficult to pretty-print JSON strings without inadvertently modifying other strings in the document.
Version of yq: 4.44.5
Operating system: linux
Installed via: binary release
Input Yaml
data.yml:
json_value: '{"key1": "value1", "key2": [1, 2, 3]}'non_json_value: "This is a plain string."
json_value: |- { "key1": "value1", "key2": [ 1, 2, 3 ] }non_json_value: This is a plain string.
Additional context
Is it possible to achieve this in a single eval-all command? Or is this a limitation of how style="literal" and select() interact within a single evaluation pass? If this is intended behavior, I’d love to understand more about why it happens.
I've also attempted to use with(), with similar results.
The text was updated successfully, but these errors were encountered:
Describe the bug
When attempting to apply
style="literal"
to JSON string values in a YAML file usingyq
, the transformation unexpectedly affects all string values, not just the targeted JSON strings, even when usingselect()
to distinguish between JSON and non-JSON values.This behavior makes it difficult to pretty-print JSON strings without inadvertently modifying other strings in the document.
Version of yq: 4.44.5
Operating system: linux
Installed via: binary release
Input Yaml
data.yml:
Command
The command I ran:
Actual behavior
Expected behavior
Workaround
A two-step
yq
command works as expected:This outputs:
Additional context
Is it possible to achieve this in a single
eval-all
command? Or is this a limitation of howstyle="literal"
andselect()
interact within a single evaluation pass? If this is intended behavior, I’d love to understand more about why it happens.I've also attempted to use
with()
, with similar results.The text was updated successfully, but these errors were encountered: