diff --git a/include/inja/environment.hpp b/include/inja/environment.hpp index a652935..9aa52ee 100644 --- a/include/inja/environment.hpp +++ b/include/inja/environment.hpp @@ -165,9 +165,8 @@ public: if (file.fail()) { INJA_THROW(FileError("failed accessing file at '" + input_path + filename + "'")); } - json j; - file >> j; - return j; + + return json::parse(std::istreambuf_iterator(file), std::istreambuf_iterator()); } /*! diff --git a/include/inja/renderer.hpp b/include/inja/renderer.hpp index f24bb91..8f813b9 100644 --- a/include/inja/renderer.hpp +++ b/include/inja/renderer.hpp @@ -458,7 +458,7 @@ class Renderer : public NodeVisitor { if (value.is_string()) { os << value.get(); // otherwise the value is surrounded with "" } else { - os << value; + os << value.dump(); } sep = separator; } diff --git a/single_include/inja/inja.hpp b/single_include/inja/inja.hpp index 6aad870..3505ee8 100644 --- a/single_include/inja/inja.hpp +++ b/single_include/inja/inja.hpp @@ -2538,7 +2538,7 @@ class Renderer : public NodeVisitor { if (value.is_string()) { os << value.get(); // otherwise the value is surrounded with "" } else { - os << value; + os << value.dump(); } sep = separator; } @@ -2867,9 +2867,8 @@ public: if (file.fail()) { INJA_THROW(FileError("failed accessing file at '" + input_path + filename + "'")); } - json j; - file >> j; - return j; + + return json::parse(std::istreambuf_iterator(file), std::istreambuf_iterator()); } /*! diff --git a/test/test.cpp b/test/test.cpp index 7645ade..5f5ed45 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -3,6 +3,8 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest/doctest.h" + +#define JSON_NO_IO 1 #include "inja/inja.hpp" const std::string test_file_directory {"../test/data/"};