Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support for json5 style comments #154

Open
glowinthedark opened this issue May 16, 2024 · 3 comments
Open

feature: support for json5 style comments #154

glowinthedark opened this issue May 16, 2024 · 3 comments
Labels
Feature Request New feature or request

Comments

@glowinthedark
Copy link

jless throws an error with JSON5-style comments:

[
  {
    "operation": "shift",
    "spec": {
      "rating": {
        "primary": {
          // simple match.  Put the value '4' in the output under the "Rating" field
          "value": "Rating",
          "max": "RatingRange"
        },
        // match any children of "rating"
        // Shiftr has a precendence order when matching, so the "*" will match "last".
        // In this case anything that isn't "primary".
        "*": {
          // &1 means, go up one level and grab that value and substitute it in
          //  in this example &1 = "quality"
          "max":   "SecondaryRatings.&1.Range",
          "value": "SecondaryRatings.&1.Value",
          //
          // We want "quality" to be a value field in the output under
          //  "SecondaryRatings.quality.Id", but "quality" is an input key not an input value.
          // The "$" operator means use the input key, instead of the input value as ouput
          "$": "SecondaryRatings.&1.Id"
        }
      }
    }
  }
]

Comments are, of course, not a part of the standard JSON spec, but it would be great to be able to have some support for certain JSON5 extensions such as comments.

@glowinthedark glowinthedark changed the title feature: json5 style comments are not supported feature: support for json5 style comments May 16, 2024
@PaulJuliusMartinez PaulJuliusMartinez added the Feature Request New feature or request label May 16, 2024
@PaulJuliusMartinez
Copy link
Owner

I expect to add support for this sometime in the next couple of months.

@glowinthedark
Copy link
Author

glowinthedark commented May 17, 2024

@PaulJuliusMartinez: given that JSON5 is apparently a more expensive grammar and, for example, python's json5 3rd party module (https://pypi.org/project/json5/) is significantly less performant than 'native' plain JSON ("1000-6000x slower than the C-optimized JSON module" according to the project page), so it might also be slower with rust JSON5 implementations; maybe it would make sense to have the ability to switch parser engines, and enable JSON5 support with a flag at the expense of performance overhead?

@PaulJuliusMartinez
Copy link
Owner

Yes, this is one of the primary concerns I am considering as I work on implementing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants