-
-
Notifications
You must be signed in to change notification settings - Fork 737
Description
Describe the bug
A clear and concise description of what the bug is.
Note that any how to questions should be posted in the discussion board and not raised as an issue.
Version of yq: v4.50.1
Operating system: Linux
Installed via: binary release
Input Toml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data1.toml:
[[array]]
[[array.subarray]]
[[array.subarray.subsubarray]]
[[array.subarray]]
[[array.subarray.subsubarray]]Command
The command you ran:
yq data1.toml
Actual behaviour
Error: bad file 'data1.toml': cannot index array with 'subarray' (strconv.ParseInt: parsing "subarray": invalid syntax)
Expected behaviour
array:
- subarray:
- subsubarray:
- {}
- subsubarray:
- {}{
"array": [
{
"subarray": [
{
"subsubarray": [{}]
},
{
"subsubarray": [{}]
}
]
}
]
}Additional context
Add any other context about the problem here.
Parsing the JSON or YAML representation of the same object works.
There are some similar issues reported, but they're usually caused by trying to extract an object that is an array:
- Error: Cannot index array with 'script' (strconv.ParseInt: parsing "XXX": invalid syntax) #1076
- multiple nested keys with special characters (Error: Cannot index array) #856
- https://stackoverflow.com/questions/69707580/update-array-value-in-yq-on-base-of-criteria
I've played around with this online toml parser, and the parsing in both directions works correctly.
Versions with a nesting layer less or if the innermost array does not have objects as values work correctly:
[[subarray]]
[[subarray.subsubarray]]
[[subarray]]
[[subarray.subsubarray]][[array]]
[[array.subarray]]
subsubarray = ["a"]
[[array.subarray]]
subsubarray = ["b"]