Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--properties-array-brackets does not seem to work when reading properties files #2253

Open
Northcode opened this issue Jan 7, 2025 · 1 comment
Labels

Comments

@Northcode
Copy link

Describe the bug
--properties-array-brackets does not seem to work when reading properties files.

Version of yq: v4.44.6
Operating system: linux
Installed via: archlinux package https://archlinux.org/packages/extra/x86_64/go-yq/

Input Properties

arr[0].name=test
arr[0].value=5
arr[1].name=test2
arr[1].value=10

Command
The command you ran:

yq -p=props -o=y --properties-array-brackets input.properties

Actual behavior

arr[0]:
  name: test
  value: "5"
arr[1]:
  name: test2
  value: "10"

Expected behavior

arr:
  - name: test
    value: "5"
  - name: test2
    value: "10"
@Northcode
Copy link
Author

Northcode commented Jan 7, 2025

This might be intended behavior, and the option is only supported for properties output instead of input.
But it wasn't very clear from the documentation since that also mentions .0 style arrays and those do work for both input and output.

$ cat | yq -p=props -o=y -
arr.0.name=test
arr.1.name=test2
^D
arr:
  - name: test
  - name: test2
$ cat | yq -p=props -o=y --properties-array-brackets -
arr[0].name=test
arr[1].name=test2
^D
arr[0]:
  name: test
arr[1]:
  name: test2

If it is not intended to work for inputs and only output, then consider this a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant