Created
May 24, 2015 13:25
-
-
Save heejune/05e1dccc33943d193352 to your computer and use it in GitHub Desktop.
cpprestsdk json test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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