jless icon indicating copy to clipboard operation
jless copied to clipboard

feature: support for json5 style comments

Open glowinthedark opened this issue 2 months ago • 3 comments

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 avatar May 16 '24 12:05 glowinthedark