Last active
April 9, 2021 09:24
-
-
Save paddy74/acbdf359ed0c3f08d4418643c328df9b to your computer and use it in GitHub Desktop.
Revisions
-
paddy74 revised this gist
Aug 20, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ #pragma once #include <cpprest/json.h> @@ -27,7 +28,7 @@ web::json::value readJsonFile(std::string const & jsonFileName) } catch (web::json::json_exception excep) { throw web::json::json_exception("Error Parsing JSON file " + jsonFileName); } return output; -
paddy74 revised this gist
Aug 20, 2019 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,9 +27,8 @@ web::json::value readJsonFile(std::string const & jsonFileName) } catch (web::json::json_exception excep) { throw web::json::json_exception("Error Parsing JSON file"); } return output; } -
paddy74 created this gist
Jun 19, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ #pragma once #include <cpprest/json.h> /** * @brief Parse a JSON file into a JSON object. * * @param jsonFileName The path to the JSON file to parse. */ web::json::value readJsonFile(std::string const & jsonFileName) { web::json::value output; // JSON read from input file try { // Open the file stream std::ifstream f(jsonFileName); // String stream for holding the JSON file std::stringstream strStream; // Stream file stream into string stream strStream << f.rdbuf(); f.close(); // Close the filestream // Parse the string stream into a JSON object output = web::json::value::parse(strStream); } catch (web::json::json_exception excep) { std::cout << "ERROR Parsing JSON: "; std::cout << excep.what(); } return output; }