[qgis-qwc2] Commenting in json files

roman.meier at gismap.ch roman.meier at gismap.ch
Wed Aug 5 23:15:33 PDT 2020


> JSON doesn't support comment natively.
> 
> see for example: https://stackoverflow.com/questions/244777/can-comments-be-used-in-json
> Cordialement/Best Regards, Rémi Desgrange

Hi Rémi

Thanks!

I have started to use commenting in my json files. Here are a few examples:

"//queryable": true,
"queryable": false,
"//displayField": "maptip",
"displayField": "note",

For titles and divisions I use something like this:

"*************************************************************":"",
"items: sdjldk************************************************":"",
"*************************************************************":"",

Debugging of json files was also a major pain for me. A great tool is jsonlint.

sudo apt install jsonlint

Example:

# jsonlint-php themes.json
themes.json: Parse error on line 944:
...:3857"      },    ],    	    "//
--------------------^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[' - It appears you have an extra trailing comma
root at tjener:/etc/debian-edu/www/prod#

Kind regards,
Roman


More information about the qgis-qwc2 mailing list