$darkmode
#include <string>#include <nlohmann/json.hpp>Go to the source code of this file.
Typedefs | |
| using | fable::Json = nlohmann::json |
| using | fable::JsonPointer = Json::json_pointer |
| using | fable::JsonType = Json::value_t |
Functions | |
| std::string | fable::to_string (JsonType) |
| template<typename InputType > | |
| Json | fable::parse_json (InputType &&input) |
Variables | |
| bool | fable::NLOHMANN_JSON_ALLOW_COMMENTS = PARSE_JSON_WITH_COMMENTS |
| bool | fable::NLOHMANN_JSON_USE_EXCEPTIONS = PARSE_JSON_USE_EXCEPTIONS |
This file provides the basic fable::Json type used to represent JSON data. For functions and other to_json functions, see files in the json/ directory.
| using fable::Json = typedef nlohmann::json |
The Json type maps to nlohmann::json.
Bringing it into the fable namespace makes it much easier to use. Making it start with capital J prevents any collision with builtins. Because it is a using statement, standard nlohmann::json constructs can be used, such as to_json and from_json.
| using fable::JsonPointer = typedef Json::json_pointer |
The JsonPointer type maps to nlohmann::json_pointer.
This makes it easier to talk/write about operations that deal with JSON pointers.
| using fable::JsonType = typedef Json::value_t |
The JsonType type maps to nlohmann::json::value_t.
This makes it easier to talk/write about operations that deal on the underlying type that is stored in a Json value.
|
inline |
Return the result of Json::parse, with the options to use exceptions and allow comments as set in this library, from NLOHMANN_JSON_USE_EXCEPTIONS and NLOHMANN_JSON_ALLOW_COMMENTS.
See the documentation on each of these global variables for more details.
| std::string fable::to_string | ( | JsonType | type | ) |
Return a string representation of a JSON type.
The returned string is one of the following values:
null object array boolean float integer unsigned string unknown
| bool fable::NLOHMANN_JSON_ALLOW_COMMENTS = PARSE_JSON_WITH_COMMENTS |
When parsing JSON from fable, should comments be allowed or lead to an exception? Value is controlled by PARSE_JSON_WITH_COMMENTS define. Default value is true.
This does not automatically apply to use of Json::parse. Instead you should use the parse_json helper function defined in this file.
| bool fable::NLOHMANN_JSON_USE_EXCEPTIONS = PARSE_JSON_USE_EXCEPTIONS |
When parsing JSON from fable, should exceptions be used? Default value is set by PARSE_JSON_WITH_COMMENTS define.
This is here for completeness. The fable library will not work correctly if exceptions are disabled, so this should always be set to true.