From a6f1c93a2bcfc4a53306cef6c526fe68be9dfac5 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Sat, 12 Nov 2016 11:11:03 +0100 Subject: [PATCH] Use semantic versioning for the --json-report format version The report now looks like: { "meta": { "type": "FlightGear JSON report", "format major version": 1, "format minor version": 0 }, ... } When making compatible changes to the format (e.g., adding members to JSON objects), only the minor version number should be increased. Increase the major version number when a change is backward-incompatible (such as the removal, renaming or semantic change of a member). Of course, incompatible changes (like this one) should only be considered as a last recourse. --- src/Main/options.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 1c5129069..b8a3edf5b 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2590,6 +2590,10 @@ void Options::showVersion() const cout << "PLIB version: " << PLIB_VERSION << endl; } +// Print a report using JSON syntax on the standard output, encoded in UTF-8. +// +// The report format is versioned, don't forget to update it when making +// changes (see below). void Options::printJSONReport() const { cJSON *rootNode = cJSON_CreateObject(); @@ -2597,7 +2601,14 @@ void Options::printJSONReport() const cJSON *metaNode = cJSON_CreateObject(); cJSON_AddItemToObject(rootNode, "meta", metaNode); cJSON_AddStringToObject(metaNode, "type", "FlightGear JSON report"); - cJSON_AddNumberToObject(metaNode, "format version", 1); + // When making compatible changes to the format (e.g., adding members to + // JSON objects), only the minor version number should be increased. + // Increase the major version number when a change is backward-incompatible + // (such as the removal, renaming or semantic change of a member). Of + // course, incompatible changes should only be considered as a last + // recourse. + cJSON_AddNumberToObject(metaNode, "format major version", 1); + cJSON_AddNumberToObject(metaNode, "format minor version", 0); cJSON *generalNode = cJSON_CreateObject(); cJSON_AddItemToObject(rootNode, "general", generalNode);