Answer the question
In order to leave comments, you need to log in
How to use json for string vector?
How to correctly implement the method for json (rapidjson library) for
My workvector<string>m_paths
rapidjson::Document jsonfile;
jsonfile.SetObject();
rapidjson::Document::AllocatorType& jsonallocator = jsonfile.GetAllocator();
std::vector<String>::iterator itm;
rapidjson::Value paths(rapidjson::kArrayType);
for(itm = m_paths.begin(); itm != m_paths.end(); ++itm)
{
//rapidjson::Value jValueConverting;
// jValueConverting.SetString(GetLogRpl().c_str(), (rapidjson::SizeType)GetLogRpl().size(), jsonallocator);
}
jsonfile.AddMember("paths", paths, jsonallocator);
rapidjson::StringBuffer jsonstring;
rapidjson::Writer<rapidjson::StringBuffer> jsonwriter(jsonstring);
jsonfile.Accept(jsonwriter);
String fullJsonString = jsonstring.GetString();
return fullJsonString;
Answer the question
In order to leave comments, you need to log in
maybe so
StringBuffer sb;
PrettyWriter writer(sb);
writer.StartObject();
writer.String(_T("paths"));
writer.StartArray();
std::vector<String>::iterator itm;
for(itm = m_paths.begin(); itm != m_paths.end(); ++itm)
{
writer.String(*itm);
}
return writer.EndArray();
writer.EndObject();
std::string fullJsonString = sb.GetString();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question