yj truncates JSON object keys containing commas when converting to TOML
When converting JSON to TOML with yj -jt, object keys containing a comma are emitted incorrectly.
For example, the JSON string:
is converted to:
instead of preserving the full key.
This appears to truncate the key at the comma, which produces invalid / incorrect TOML output.
Reproduce the issue with:
echo '{"stack(x,n)":"foobar"}' | yj -jt
Observed output:
The full key should be preserved in the generated TOML, for example something like:
I first hit this through Nix, where TOML generation recently switched to yj in NixOS/nixpkgs (NixOS/nixpkgs#510585). The following repro in the Nix REPL shows the same problem:
builtins.readFile ((pkgs.formats.toml {}).generate "jj" { "stack(x,n)" = "foobar"; })
which produces:
"\"stack(x\" = \"foobar\"\n"
For comparison, another JSON→TOML converter (https://github.com/pelletier/go-toml) preserves the key correctly:
echo '{"stack(x,n)":"foobar"}' | jsontoml
Output:
yjtruncates JSON object keys containing commas when converting to TOMLWhen converting JSON to TOML with
yj -jt, object keys containing a comma are emitted incorrectly.For example, the JSON string:
{"stack(x,n)":"foobar"}is converted to:
instead of preserving the full key.
This appears to truncate the key at the comma, which produces invalid / incorrect TOML output.
Reproduce the issue with:
Observed output:
The full key should be preserved in the generated TOML, for example something like:
I first hit this through Nix, where TOML generation recently switched to
yjinNixOS/nixpkgs(NixOS/nixpkgs#510585). The following repro in the Nix REPL shows the same problem:which produces:
For comparison, another JSON→TOML converter (https://github.com/pelletier/go-toml) preserves the key correctly:
Output: