jsoncpp

jsoncpp

简介

用法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// build:  -ljson
#include "json/json.h"

string func() {
        Json::Value person;
    person["ID"] = student.ID;
    person["name"] = student.name;
    person["age"]=student.age;
    person["gender"]=student.gender;
    person["major"]=student.major;

   Json::StreamWriterBuilder builder;
   ostringstream oss;
   //builder.settings_["indentation"] = "";
   std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
   writer->write(person, &oss);
   return oss.str();
}
updatedupdated2024-08-252024-08-25