Skip to content

Add JSON5 support? #33

@GWRon

Description

@GWRon

For now we have Jansson.mod utilized for json.mod.

Would it make sense to also support json5? The main benefit (for me) of json5 is the comment support and the multiline strings. They increase "readability" a lot.

When just using it as "readable datastorage" then json will be enough but some advanced "config files" mit benefit from commands.
I guess vscode internally uses json5 too as the launch.json files there allow comments ... so maybe a good example of "how it can be good".

Json5:
https://json5.org

Sample json5 file:
https://github.com/chromium/chromium/blob/feb3c9f670515edf9a88f185301cbd7794ee3e52/third_party/blink/renderer/platform/runtime_enabled_features.json5

I am not aware of "the best c-library" for json5 (and the original implementation is TypeScript) so I just had a look what exists (amongst others):

https://github.com/detomon/json5

https://gist.github.com/inlife/b54a0d9228e428284e1d8eccbed97e35
-> but comments to that single-file-gist tell to use the newer one which can be extracted from the zpl-collection (which itself could have interesting things ...):
https://github.com/zpl-c/zpl/blob/master/code/source/parsers/json.c

Dunno if these implementations have issues with utf8 or so but they look rather "lightweight". Maybe UTF8-Handling can be done "afterwards" (similar to reading files with filestream.mod now).

Thoughts?

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