$darkmode
json.hpp File Reference
#include <string>
#include <nlohmann/json.hpp>
#include <fable/fable_fwd.hpp>
Include dependency graph for json.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

using fable::JsonType = nlohmann::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
 

Detailed Description

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.

Typedef Documentation

◆ JsonType

using fable::JsonType = typedef nlohmann::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.

Examples
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.23.0/fable/include/fable/schema.hpp, and /home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.23.0/fable/include/fable/schema/interface.hpp.

Function Documentation

◆ parse_json()

template<typename InputType >
Json fable::parse_json ( InputType &&  input)

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string()

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

Variable Documentation

◆ NLOHMANN_JSON_ALLOW_COMMENTS

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.

◆ NLOHMANN_JSON_USE_EXCEPTIONS

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.