0

Trying to integrate rapidjson into my app. Used to read a (validated with an online tool) simple config file like:

{
    "filecontent": "appsettings",
    "fileversion": 1,
    "appsettings": {
        "general": {
            "sync": "false",
            "sound": "true"
        },
...

This is my code:

QString path = keypath( key ); //.prepend("/");
rapidjson::Value* hello = rapidjson::Pointer( "/appsettings/general/sound" ) //path.toStdString().c_str()
                          .Get(rapidJsonDoc_);

if ( hello ) {
    QVariant retStr( hello->GetString() );
    qDebug()<<"--> " <<path<<" --> " << retStr;
    ret = QVariant::fromValue( retStr );
}else{
    qDebug()<<"Value not found!";
}
return ret;

If I prepend the pointer string with /, as I understand the examples, it says value not found. If I remove the slash, if (hello) is true, but does not return an expected value.

rapidJsonDoc_ is of type rapidjson::Document.

Please help me with the correct syntax. I am looking at the source code of rapidjson and can't understand a thing, it is so full of templates and complex signatures...

update:

according to this post modifying a Qt QJsonDocument is not possible like I want.

Community
  • 1
  • 1
user2366975
  • 4,350
  • 9
  • 47
  • 87
  • 1
    Since you're already using Qt, why not just use [its built-in Json support](http://doc.qt.io/qt-5/json.html)? – MrEricSir Apr 13 '17 at 22:34
  • Because I could not figure out how to write a document by just passing a string path like above (aka pointer) and a value. For reading I implemented the pointer myself, before finding out that rapidjson has the pointer stuff buildin. – user2366975 Apr 13 '17 at 22:36

0 Answers0