CSV conversion to JSON splits string on : to become a subfield. #1947
Closed
Description
When transforming CSV strings to JSON objects. Strings that contains : will be split into a field.
With the field name being the LHS of the : and the value being the RHS.
Version of yq: 4.40.4
Operating system: WSL using linxbrew
Installed via: homebrew
Input CSV
id,mystring
1,hello world
2,hello: world
Command
The command you ran:
yq -o=json ./csv/bug2.csv
Actual behavior
[
{
"id": 1,
"mystring": "hello world"
},
{
"id": 2,
"mystring": {
"hello": "world"
}
}
]
Expected behavior
[
{
"id": 1,
"mystring": "hello world"
},
{
"id": 2,
"mystring":"hello: world"
}
}
]
Additional context
It also fails when using quoted strings.
"id","mystring"
"1","hello world"
"2","hello: world"