Skip to content

Use of Different JSON Library for Unmarshalling JSON for VS Code Settings #117

Closed

Description

@ChrisJBurns

In a debugging session with @danbarr it was discovered that thv couldn't read his VS Code settings.json because it had comments in them (// comment) and trailing commas in single line arrays and objects. Typically JSON doesn't have comments, but VS Code supports them, and sometimes, extensions you install add the comments themselves.

In case of users having comments in their VS Code files, should we, in the case for settings.json unmarshalling, use a JSON Go library that supports comments in JSON? Or perhaps write some logic to ignore the comments syntax in the settings.json file. This eases the burden on those who have settings.json files with comments in them and not requiring them to rewrite them to use thv.

Example libraries:

Activity

  1. danbarr commented on Apr 7, 2025

    @danbarr
    Collaborator

    After removing the commented lines, I hit a second validation error. This one I can't pin down:

    Error reading client config file /Users/dan/Library/Application Support/Code/User/settings.json: failed to parse JSON: invalid character '}' looking for beginning of object key string
    
  2. ChrisJBurns commented on Apr 7, 2025

    @ChrisJBurns
    CollaboratorAuthor

    The above seemed to have been a trailing comma on single line objects. Will wait for @danbarr to confirm if that was the last of the issues.

  3. danbarr commented on Apr 7, 2025

    @danbarr
    Collaborator

    Yes after cleaning my config of all commented lines and trailing commas (which VS Code also supports and routinely adds), thv was able to insert the mcp section as expected.

    Secondary issue: when it wrote back my config, it had re-ordered every entry alphabetically 🙃

  4. added
    bug
    p1
    on Apr 8, 2025
  5. JAORMX commented on Apr 10, 2025

    @JAORMX
    Collaborator

    This will be covered by #156 . Let's make sure the work there addresses this. cc @dmjb

  6. added
    p0
    and removed
    p1
    on Apr 10, 2025
  7. assigned and unassigned on Apr 10, 2025
  8. danbarr commented on Apr 15, 2025

    @danbarr
    Collaborator

    Looks good @ChrisJBurns !

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugp0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions