Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relaxed syntax for JSON #41

Closed
4 tasks done
matyalatte opened this issue Jul 21, 2024 · 2 comments
Closed
4 tasks done

Relaxed syntax for JSON #41

matyalatte opened this issue Jul 21, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@matyalatte
Copy link
Owner

matyalatte commented Jul 21, 2024

Some new rules for gui_definition.json. They will make it easier for users to manage JSON files.

  • Allow comments
  • Allow an object instead of an array of an object.
  • Allow the "gui" object as root.
  • Allow trailing commas at the end of objects and arrays.

Allow comments

C-style comments (// ... and /* ... */) improve readability.

{
    /*
    comments
    */
    "gui": [{}]  // comments
}

Allow an object instead of an array of an object.

The array brackets [] (and the indnetation for them) are redundant when it has only one item.

"gui": //[
{
    "label": "no need the array brackets when it has only one item"
}
//]

Allow the "gui" object as root.

The root braces {} and the key gui are redundant when there is only the "gui" object.

// { "gui":
{
    "label": "no need the root braces when there is no other keys."
}
// }

Allow trailing commas at the end of objects and arrays.

When managing json files in git, adding a trailing comma at the end of objects and arrays makes the commit history cleaner.

[
    "need a trailing comma",
    "need a trailing comma",
    "no need a trailing comma but you can put it",
]
@matyalatte matyalatte added the enhancement New feature or request label Jul 21, 2024
@matyalatte
Copy link
Owner Author

Comments and trailing commas are supported at #42

@matyalatte
Copy link
Owner Author

You can now remove array brackets when it has only one item. (#51)
and you can also move gui elements (e.g. "command") into the root object. (#52)
like this

{
    "minimum_required": "0.8.0",
    // no need for "gui"
    "label": "test",
    "command": "echo hello",
    "components": [],
    // no need for array brakets [] for "help"
    "help": {
        "label": "test",
        "type": "url",
        "url": "example.com",
    },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant