Skip to content

Support .json5 extension #1916

Description

@djgoku

What problem are you trying to solve?

I want to validate my devbox.json and plugin.json with check-jsonschema which can validate both .json and .json5 files.

Validate devbox.json

dj_goku % devbox init
dj_goku % devbox add python311Packages.json5 check-jsonschema
Info: Adding package "python311Packages.json5@latest" to devbox.json
Info: Adding package "check-jsonschema@latest" to devbox.json
dj_goku % devbox shell
✓ Computed the Devbox environment.
Starting a devbox shell...
(devbox) dj_goku % check-jsonschema --schemafile https://raw.githubusercontent.com/jetpack-io/devbox/main/.schema/devbox.schema.json devbox.json 
ok -- validation done
(devbox) dj_goku % cat devbox.json 
{
  "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.1/.schema/devbox.schema.json",
  "packages": [
    "python311Packages.json5@latest",
    "check-jsonschema@latest"
  ],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

validate devbox.json5

(devbox) dj_goku % check-jsonschema --schemafile https://raw.githubusercontent.com/jetpack-io/devbox/main/.schema/devbox.schema.json devbox.json5
ok -- validation done
(devbox) dj_goku % cat devbox.json5
{
  // a comment
  "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.1/.schema/devbox.schema.json",
  "packages": [
    "python311Packages.json5@latest",
    "check-jsonschema@latest"
  ],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}
(devbox) dj_goku % diff -u devbox.json devbox.json5
--- devbox.json	2024-03-21 18:43:04.503029111 -0500
+++ devbox.json5	2024-03-21 18:44:21.621139194 -0500
@@ -1,4 +1,5 @@
 {
+  // a comment
   "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.1/.schema/devbox.schema.json",
   "packages": [
     "python311Packages.json5@latest",

What solution would you like?

The ability to use .json (without comments) or .json5 (with comments).

Alternatives you've considered

I can copy devbox.json5 to devbox.json and use this newly copied devbox.json with devbox shell.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requesttriageIssue needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions