denoland / denoland/std

std/jsonc seems to strip comments

Open
#3,502 17 comments 0 reactions 1 assignee Claimed by @mmuddasani View on GitHub
bug needs triage
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

esm.sh is currently unable to update an existing deno.jsonc file. See: https://github.com/esm-dev/esm.sh/issues/686.
While implementing, it came to light, that the jsonc parser in the deno std lib seems to discard comments.
(see this issue, comment by farsightsoftware: https://github.com/esm-dev/esm.sh/issues/687)

I've not checked it myself yet, but I asked farsightsoftware to add an example to this issue.

The main usecase for this std lib is currently updating the deno.jsonc file, so it would make it a lot easier for all tools dealing with the deno.jsonc file if it would preserve comments automatically.

**Steps to Reproduce**

TODO

**Expected behavior**

The jsonc parser output is able to be stringified again and produce identical output to the original jsonc input.

In diagram:

jsonc file
=> jsonc parser
=> some intermediate representation
=> jsonc stringifier
=> a file identical to the original jsonc file
(especially with comments)

**Environment**

TODO

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.