Skip to content

Outputs invalid JSON int values (erroneously uses locale formatting) #722

@davidljung

Description

@davidljung

When I pass in a Jsonnet string like:
{ type: "int", limited: true, min: 0, max: 2000, params: [ "RS34" ] }

and execute it using the C++ API via evaluateSnippet(), the resulting string is:

{ "limited": true, "max": 2,000, "min": 0, "params": [ "RS34" ], "type": "int" }

which isn't valid JSON (notice the extra comma for the thousands position for the 2000).

This is likely the result of using a std::ostream for formatting integers, without correctly setting the numpunct to empty (resulting in the comma for the current locale being used). This is US English locale - I suspect for a Euro locale it might result in "2.000"!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions