JSONCPP有一个编写器,但它似乎只是从解析器获取信息,然后将其输出到字符串或流中.如何更改或创建新对象,数组,值,字符串等并将其写入文件?
所以我最近安装了JSONCPP,出于某种原因,当我尝试这段代码时它给了我错误:
#include <json.h>
#include <iostream>
#include <fstream>
int main(){
bool alive = true;
while (alive){
Json::Value root; // will contains the root value after parsing.
Json::Reader reader;
std::string test = "testis.json";
bool parsingSuccessful = reader.parse( test, root, false );
if ( !parsingSuccessful )
{
// report to the user the failure and their locations in the document.
std::cout << reader.getFormatedErrorMessages()
<< "\n";
}
std::string encoding = root.get("encoding", "UTF-8" ).asString();
std::cout << encoding << "\n";
alive = false;
}
return 0; …Run Code Online (Sandbox Code Playgroud) 我该如何构建它?文档真的很阴暗.它说你需要将scons.py放在目录中,但我不知道它在哪里.我尝试使用包含的prebuild,但它没有生成任何.lib文件.