Skip to content

Instantly share code, notes, and snippets.

@heejune
Created May 24, 2015 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heejune/05e1dccc33943d193352 to your computer and use it in GitHub Desktop.
Save heejune/05e1dccc33943d193352 to your computer and use it in GitHub Desktop.
cpprestsdk json test
#include <cpprest\json.h>
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
web::json::value root;
std::wstring filepath = L"config.json";
std::ifstream ifs;
ifs.open(filepath.c_str(), std::ifstream::in);
if (ifs)
{
try {
auto jsonResult = web::json::value::parse(ifs);
auto value = jsonResult.at(L"key").as_string();
auto value2 = jsonResult.at(L"anotherkey").as_string();
auto value3 = jsonResult.at(L"last").as_string();
}
catch (const std::exception& e) {
std::string reason = e.what();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment