Skip to content

Support Json5 features #1152

Open
Open

Description

JSON5 brings ECMAScript 5.1 features to JSON. Jsonnet supports most of the JSON5 features with a few exceptions:

  • Strings may span multiple lines by escaping new line characters.
  • Numbers may be hexadecimal.
  • Numbers may have a leading or trailing decimal point.
  • Numbers may be IEEE 754 positive infinity, negative infinity, and NaN.

This means that the following JSON5 file cannot be properly loaded as valid Jsonnet:

{
  lineBreaks: "Look, Mom! \
No \\n's!",
  hexadecimal: 0xdecaf,
  leadingDecimalPoint: .8675309, andTrailing: 8675309.,
  nan: NaN, infinity: Infinity,
}

These features would be great additions to Jsonnet. Supporting them will make Jsonnet a superset of JSON5 and thus make the migraion from JSON5 to Jsonnet much easier. Additionally, these features are mostly backward-compatible with existing Jsonnet syntax (except NaN and Infinity). Please consider supporting them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    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