#include#include int main() { Json::Value val("Hello World!"); const char* str = val.asCString(); std::cout << str << std::endl; return 0; }
#includeIn this example, a JSON string is parsed using the Json::Reader library and converted to a JSON value. The "name" element of the JSON value is then extracted as a C-style string using the asCString function and printed to the console. The cpp json library used in the examples is JsonCpp.#include int main() { std::string json_str = "{\"name\":\"John\",\"age\":30,\"city\":\"New York\"}"; Json::Value val; Json::Reader reader; reader.parse(json_str, val); const char* name = val["name"].asCString(); std::cout << "Name: " << name << std::endl; return 0; }