I'm looking at using RapidJSON to convert some data strings to json format. This is what I have as my starting point.
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <iostream>
using namespace rapidjson;
using namespace std;
std::string item_name
std::string item_address
itemname = "John";
item_address = "New York";
int main() {
StringBuffer s;
writer<StringBuffer> writer(s);
writer.StartObject();
writer.String("hello");
writer.EndObject();
std:cout << s.GetString() <<endl;
return 0;
}
The output format would be something like this:
{"item": {"name": "John", "address": "New York"}}
I'm confused about how I am meant to put my string contents into the json, as well as define that it should be a child of "item". Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire