read file
diff --git a/src/main.cpp b/src/main.cpp index 87f8949..478f3ce 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -1,10 +1,27 @@ // #include <iostream> #include "rapidjson/document.h" #include <cstdio> +#include <fstream> +#include <string> +#include <exception> + +std::string read_file(const char* filename) { + std::ifstream input_file(filename); + if(input_file.good()) { + std::string json_str( + (std::istreambuf_iterator<char>(input_file)), + std::istreambuf_iterator<char>() + ); + return json_str; + } else { + std::printf("Error reading file %s", filename); + throw std::exception(); + } +} int main(int, char* argv[]) { const char* filename = argv[1]; - // std::cout << filename << std::cou; - // std::printf("Hello, world!\n"); - std::printf("%s", filename); + std::string json = read_file(filename); + // std::printf("%s\n", json.c_str()); + // std::printf("%s", json.c_str()); }