#include "dg/file/json_utilities.h" (link -ljsoncpp)
◆ comments
Switch how comments are treated in a json string or file.
Enumerator |
---|
are_kept | Keep comments in the Json value.
|
are_discarded | Allow comments but discard them in the Json value.
|
are_forbidden | Treat comments as invalid Json.
|
◆ error
Switch between how to handle errors in a Json utitlity functions.
Enumerator |
---|
is_throw | throw an error
|
is_warning | Handle the error by writing a warning to std::cerr .
|
is_silent | Ignore the error and silently continue execution.
|
◆ file2Json()
Convenience wrapper to open a file and parse it into a Json::Value.
- Note
- included in
json_utilities.h
- Parameters
-
filename | Name of the JSON file to parse |
js | Contains all the found Json variables on output |
comm | determines the handling of comments in the Json file |
err | determines how parser errors are handled by the function error::is_throw: throw a std::runtime_error containing an error message on any error that occurs on parsing; error::is_warning: write the error message to std::cerr and return; error::is_silent: silently return |
◆ string2Json()
Convenience wrapper to parse a string into a Json::Value.
Parse a string into a Json Value
- Attention
- This function will throw a
std::runtime_error
with the Json error string on any error that occurs on parsing.
- Note
- included in
json_utilities.h
- Parameters
-
input | The string to interpret as a Json string |
js | Contains all the found Json variables on output |
comm | determines the handling of comments in the Json string |
err | determines how parser errors are handled by the function error::is_throw: throw a std::runtime_error containing an error message on any error that occurs on parsing; error::is_warning: write the error message to std::cerr and return; error::is_silent: silently return |