Skip to content

std.parseYaml() parses quoted numbers as numbers #1050

Closed
@vincentmrg

Description

@vincentmrg

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions