[Qt-creator] Validating JSON files

Mitch Curtis mitch.curtis at qt.io
Thu Aug 2 17:22:27 CEST 2018


I recently checked if Qt Creator supports any kind of JSON validation (e.g. JSON lint). I found this page:

http://doc.qt.io/qtcreator/creator-checking-code-syntax.html#checking-json-data-structure

Quoting the section:

“You can run static checks on the QML and JavaScript code in your project to find common problems.

Qt Creator validates instances of JSON entities against A JSON Media Type for Describing the Structure and Meaning of JSON Documents. However, Qt Creator does not understand the entire specification.

A JSON schema defines the structure of JSON data. It determines what JSON data is required for an application and how to interact with it.

The specification does not define how to map JSON instances with JSON schemas. Qt Creator looks for a JSON schema file with a name that matches the name of the JSON instance file in the user configuration folder. For example, ~/config/QtProject/qtcreator/json on Linux and macOS and C:\Users\username\AppData\Roaming\QtCreator\qtcreator\json in Windows. To check JSON data structure, copy the JSON schema file to the above folder.”

Does this mean that if I want to validate a regular JSON file, I need to have my own schema? Why not provide a default schema so that there is an equivalent to the results that e.g. JSON lint would give? Just for kicks, I tried running Ctrl+Shift+C with a JSON file open (which couldn’t be loaded by QJsonDocument due to errors), but Creator didn’t show any entries for it in the Issues pane.

Also, why are the “Checking JavaScript and QML Syntax” and “List of JavaScript and QML Checks” sub-sections of a JSON section? QML and JavaScript are not subsets of JSON, and it makes reading this entire section very difficult.



More information about the Qt-creator mailing list