解析时JSON C ++分段错误

时间:2015-02-16 15:36:58

标签: c++ json parsing

我想使用jsoncpp来解析文件中的JSON密钥和值,使用与this example中类似的代码。

我的代码:



        Json::Value root;
        Json::Reader reader;
        ifstream test("example2.json",ifstream::binary);
        bool success=reader.parse(test,root,false);
        if(!success){
            cout<<"Failed to parse received reply from DYAMAND\n"<<reader.getFormattedErrorMessages();
            return;
        }


        string id = root["id"];
        cout<<id<<"\n";
        
&#13;
&#13;
&#13;

非常简单的代码,但我无法找到解决此错误的方法。从文件中读取时,段落故障的建议方法似乎都不起作用。

有谁知道如何解决这个问题?

0 个答案:

没有答案