Json::Value obj; obj["name"] = "John"; obj["age"] = 25; obj["country"] = "USA"; Json::FastWriter writer; std::string json = writer.write(obj); std::cout << json << std::endl;
{"name":"John","age":25,"country":"USA"}
Json::Value arr; arr.append("apple"); arr.append("banana"); arr.append("orange"); Json::FastWriter writer; std::string json = writer.write(arr); std::cout << json << std::endl;
["apple","banana","orange"]Overall, using FastWriter from the JsonCpp library allows for quick and efficient conversion of JSON data into a string format.