|  | MySQL 9.5.0
    Source Code Documentation | 
| Namespaces | |
| namespace | anonymous_namespace{utils_json.cc} | 
| Typedefs | |
| using | JSON = rapidjson::Document | 
| Functions | |
| JSON | parse (std::string_view json) | 
| Parses a JSON string.  More... | |
| JSON | parse_object_or_throw (std::string_view json) | 
| Parses a JSON string, input is expected to be a JSON object.  More... | |
| std::string | required (const JSON &json, const char *name, bool allow_empty=false) | 
| Fetches a string value of a required field.  More... | |
| uint64_t | required_uint (const JSON &json, const char *name) | 
| Fetches an unsigned integer value of a required field.  More... | |
| std::optional< std::string > | optional (const JSON &json, const char *name, bool allow_empty=false) | 
| Fetches a string value of an optional field.  More... | |
| std::optional< uint64_t > | optional_uint (const JSON &json, const char *name) | 
| Fetches an unsigned integer value of an optional field.  More... | |
| std::string | to_string (const JSON &json) | 
| Converts a JSON object to a string.  More... | |
| std::string | to_pretty_string (const JSON &json) | 
| Converts a JSON object to a nicely formatted string.  More... | |
| using shcore::json::JSON = typedef rapidjson::Document | 
| std::optional< std::string > shcore::json::optional | ( | const JSON & | json, | 
| const char * | name, | ||
| bool | allow_empty = false | ||
| ) | 
Fetches a string value of an optional field.
| json | JSON object. | 
| name | Name of the field. | 
| allow_empty | Don't throw if value is an empty string. | 
| std::runtime_error | if value is not a string | 
| std::optional< uint64_t > shcore::json::optional_uint | ( | const JSON & | json, | 
| const char * | name | ||
| ) | 
Fetches an unsigned integer value of an optional field.
| json | JSON object. | 
| name | Name of the field. | 
| std::runtime_error | if value is not an unsigned integer | 
| JSON shcore::json::parse | ( | std::string_view | json | ) | 
Parses a JSON string.
NOTE: this does not throw exceptions, parsed document can be potentially invalid.
| json | JSON to be parsed. | 
| JSON shcore::json::parse_object_or_throw | ( | std::string_view | json | ) | 
Parses a JSON string, input is expected to be a JSON object.
| json | JSON to be parsed. | 
| std::runtime_error | if parsing fails, or result is not a JSON object. | 
| std::string shcore::json::required | ( | const JSON & | json, | 
| const char * | name, | ||
| bool | allow_empty = false | ||
| ) | 
Fetches a string value of a required field.
| json | JSON object. | 
| name | Name of the field. | 
| allow_empty | Don't throw if value is an empty string. | 
| std::runtime_error | if field does not exist or its value is not a string | 
| uint64_t shcore::json::required_uint | ( | const JSON & | json, | 
| const char * | name | ||
| ) | 
Fetches an unsigned integer value of a required field.
| json | JSON object. | 
| name | Name of the field. | 
| std::runtime_error | if field does not exist or its value is not an unsigned integer | 
| std::string shcore::json::to_pretty_string | ( | const JSON & | json | ) | 
Converts a JSON object to a nicely formatted string.
| json | A JSON object | 
| std::string shcore::json::to_string | ( | const JSON & | json | ) | 
Converts a JSON object to a string.
| json | A JSON object |