Toxblh / MTMR

🌟 [My TouchBar My rules]. The Touch Bar Customisation App for your MacBook Pro
https://mtmr.app
MIT License
4.22k stars 220 forks source link

Support comments inside of the Json #35

Closed danillos closed 6 years ago

danillos commented 6 years ago

Currently when is added \\ it shows as a bad preset

ad commented 6 years ago

No, comments of the form //… or / … / are not allowed in JSON. This answer is based on: http://www.json.org RFC 4627: The application/json Media Type for JavaScript Object Notation (JSON) RFC 7159 The JavaScript Object Notation (JSON) Data Interchange Format - Obsoletes: 4627, 7158

but... you can use this method:

    {
        "type": "escape",
        "type": "this is comment",
        "width": 64,
        "width": "element width",
        "align": "left",
        "align": "alignment of element"
    },
danillos commented 6 years ago

@ad Good point but JSON wasn't created to be used as a configuration file too.

I don't see why not support it, a configuration file without comments is hard to do tests and doesn't allow add comments to explain the configurations.

See sublime configuration file as example:

// Place your settings in the file "Packages/User/Preferences.sublime-settings",
// which overrides the settings in here.
//
// Settings may also be placed in syntax-specific setting files, for
// example, in Packages/User/Python.sublime-settings for python files.
{
    // Sets the colors used within the text area
    "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",

    // Note that the font_face and font_size are overridden in the platform
    // specific settings file, for example, "Preferences (Linux).sublime-settings".
    // Because of this, setting them here will have no effect: you must set them
    // in your User File Preferences.
    "font_face": "",
    "font_size": 10,

    // Valid options are "no_bold", "no_italic", "no_antialias", "gray_antialias",
    // "subpixel_antialias", "no_round" (OS X only), "gdi" (Windows only) and
    // "directwrite" (Windows only)
    "font_options": [],
    // Font options for theme text. Valid options are: "n
    // ...
}

One way to implement it: http://blach.io/2014/07/28/nsjsonserialization-category-to-read-json-with-comments/

ad commented 6 years ago

https://github.com/PureSwift/JSONC

ad commented 6 years ago

PR #39

Toxblh commented 6 years ago

merged!