Skip to content

Latest commit

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

QJsonSettings

Qt QSettings in JSON format.

Quick Start

Source code:

#include<QtCore/QCoreApplication>
#include<qjsonsettings.h>staticauto JSONFormat = QSettings::InvalidFormat;
intmain(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
// Register JSON format
JSONFormat = QJsonSettings::registerFormat();
QSettings settings("settings.json", JSONFormat);
settings.setValue("a", 1);
settings.setValue("b/c", true);
settings.setValue("d/e/f", "Hello World!");
settings.setValue("foo", "foo");
settings.setValue("foo/bar", "foo/bar");
settings.sync();
return0;
}

Output settings file:

{
"a": 1,
"b": {
"c": true
},
"d": {
"e": {
"f": "Hello World!"
}
},
"foo": {
"$value": "foo",
"bar": "foo/bar"
}
}

Reserved Keys

  • $value: If the current key has subkeys, its value is stored in the $type property
  • $type/$data: If the value is of a complex type, it is stored using a json object in the following format:
    {
    "$type": "<qt metatype id>",
    "$data": "<serialized data>"
    }

About

Qt QSettings in JSON format.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages