jsonnet
jsonnet copied to clipboard
std.parseYaml() parses quoted numbers as numbers
Hello,
It looks like the std.parseYaml
function parses quoted numbers as numbers (instead of string).
e.g.
bash-5.1$ cat test.jsonnet
local yaml = 'id: "91372278466"\nname: staging\n';
std.parseYaml(yaml)
bash-5.1$ jsonnet test.jsonnet
{
"id": 91372278466,
"name": "staging"
}
Another unexpected behavior is that this function fails if said number starts with a 0. e.g.
bash-5.1$ cat test.jsonnet
local yaml = 'id: "091372278466"\nname: staging\n';
std.parseYaml(yaml)
bash-5.1$ jsonnet test.jsonnet
Something went wrong during jsonnet_evaluate_snippet, please report this: [json.exception.parse_error.101] parse error at line 1, column 19: syntax error while parsing object - unexpected number literal; expected '}'
Abort trap: 6
I'm guessing this is an issue with the underlying parser? Was it C++ or Go
It was with the C++ version. I just tested with the go implementation, it works fine.
It's probably a bug in RapidYAML then
This one should be fixed by #1134 (upgrading RapidYAML to 0.5.0)
Should work on master now. I have added a test case for it (#1136). Thanks for the bug report!