Skip to content

Can we have in json_strip_comments() additional functionallity that removes trailing commas? #612

@Tal500

Description

@Tal500

See JSON5 capabilities from https://github.com/Joakker/lua-json5?tab=readme-ov-file#so-why-should-i-use-this-instead-of-the-builtin-json_decode:

The advantage this package has over regular json, however, is that you get json5 features, such as comments, trailing commas and more flexible string literals.

So basically JSON5 added capabilities/syntax:

  1. comments
  2. trailing commas
  3. more flexible string literals (don't know what it means)

This package have a support for 1 via the function json_strip_comments(), but doesn't have a support for removing trailing commas, even though it seems that all the complex code is there, and with a little extra effort we can have a reg expression or such that detects the patterns ,(whitespace)} and ,(whitespace)] easily.
Not sure about 3, what it means and if we want it.

Basically, the nice function we could have is a transformer from JSON5 to JSON.

Metadata

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