Maze Builder Docs 6.0.1
Loading...
Searching...
No Matches
mazes::json_helper Class Reference

JSON helper class. More...

#include <json_helper.h>

Public Member Functions

 json_helper ()
 Default constructor.
 
 ~json_helper ()
 Destructor.
 
 json_helper (const json_helper &other)
 
json_helperoperator= (const json_helper &other)
 
 json_helper (json_helper &&other) noexcept=default
 
json_helperoperator= (json_helper &&other) noexcept=default
 
std::string from (const std::unordered_map< std::string, std::string > &map, int pretty_print=4) const noexcept
 Get the contents of a map as a string in JSON format.
 
bool from (const std::string &s, std::unordered_map< std::string, std::string > &m) const noexcept
 Parse and set a JSON string into a C++ map.
 
bool load (const std::string &filename, std::unordered_map< std::string, std::string > &m) const noexcept
 Parse a JSON file into a C++ map from a file on disk.
 

Detailed Description

JSON helper class.

This class provides methods to convert a map of strings into a JSON string

Member Function Documentation

◆ from() [1/2]

bool mazes::json_helper::from ( const std::string & s,
std::unordered_map< std::string, std::string > & m ) const
noexcept

Parse and set a JSON string into a C++ map.

Parameters
s
m
Returns
success or failure on parse

◆ from() [2/2]

std::string mazes::json_helper::from ( const std::unordered_map< std::string, std::string > & map,
int pretty_print = 4 ) const
noexcept

Get the contents of a map as a string in JSON format.

Parameters
map
pretty_printNumber of spaces to use for indenting the JSON string
Returns

◆ load()

bool mazes::json_helper::load ( const std::string & filename,
std::unordered_map< std::string, std::string > & m ) const
noexcept

Parse a JSON file into a C++ map from a file on disk.

Parameters
filename
m
Returns


The documentation for this class was generated from the following file: