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