JsonIO.cpp
Go to the documentation of this file.
1#include "JsonIO.h"
2
4{
5
6
7 void
8 JsonIO::writeJson(const std::string& filename,
9 const nlohmann::json& j,
10 int indent,
11 char indentChar)
12 {
13 std::ofstream ofs(filename);
14 writeJson(ofs, j, indent, indentChar);
15 }
16
17 void
18 JsonIO::writeJson(std::ostream& os, const nlohmann::json& j, int indent, char indentChar)
19 {
20 os << j.dump(indent, indentChar);
21 }
22
23 nlohmann::json
24 JsonIO::readJson(const std::string& filename)
25 {
26 std::ifstream ifs(filename);
27 return readJson(ifs);
28 }
29
30 nlohmann::json
31 JsonIO::readJson(std::istream& is)
32 {
33 nlohmann::json j;
34 is >> j;
35 return j;
36 }
37
38
39} // namespace visionx::voxelgrid::io
static nlohmann::json readJson(const std::string &filename)
Read JSON from file.
Definition JsonIO.cpp:24
static void writeJson(const std::string &filename, const nlohmann::json &j, int indent=-1, char indentChar=' ')
Write JSON json to file.
Definition JsonIO.cpp:8