MySQL 9.3.0
Source Code Documentation
helper::json Namespace Reference

Namespaces

namespace  sql
 

Classes

class  ExtractSubObjectHandler
 
class  IterableArray
 
class  IterableObject
 
class  RapidReaderHandlerStringValuesToStruct
 
class  RapidReaderHandlerToMapOfSimpleValues
 This class is a adapter for Reader from RapidJson. More...
 
class  RapidReaderHandlerToStruct
 This class is a adapter for Reader from RapidJson. More...
 
class  SerializerToText
 

Typedefs

template<typename T >
using Writer = rapidjson::Writer< T >
 
using MapObject = std::map< std::string, std::string >
 std::map that represents simple JSON object. More...
 

Functions

std::optional< bool > to_bool (const std::string &value)
 
std::optional< bool > to_bool (const rapidjson::Value &value)
 
std::string merge_objects (const std::string &j1, const std::string &j2, const std::set< std::string > &skip_attributes)
 
std::optional< std::string > merge_objects (std::optional< std::string > j1, std::optional< std::string > j2, const std::set< std::string > &skip_attributes)
 
template<typename Obj >
auto member_iterator (Obj &o)
 
auto array_iterator (const rapidjson::Value::ConstArray &o)
 
auto array_iterator (rapidjson::Value::Array &o)
 
template<template< typename > typename Writer = Writer, typename JsonValue >
void rapid_json_to_text (JsonValue *json_value, std::string &text_value)
 
template<template< typename > typename Writer = Writer, typename JsonValue >
void append_rapid_json_to_text (JsonValue *json_value, std::string &text_value)
 
std::string to_string (const rapidjson::Value &value)
 
bool validate_json_with_schema (const std::string &json, const std::string &schema, std::string *error_description=nullptr)
 
template<typename Handler , typename Container >
bool text_to (Handler *handler, const Container &c)
 Convert text representation of json object/value to type defined by 'Handler'. More...
 
template<typename Container >
bool text_to (rapidjson::Document *doc, const Container &c)
 
bool text_to (rapidjson::Document *doc, const std::string &str)
 
bool text_to (rapidjson::Document *doc, const char *str)
 
bool text_to (rapidjson::Document::Object *obj, const std::string &str)
 
bool text_to (rapidjson::Value *val, const std::string &str)
 
template<typename Handler , typename Container , typename... HandlerArgs>
Handler::Result text_to_handler (const Container &c, HandlerArgs &&...args)
 Convert text representation of json object/value to type defined by 'Handler'. More...
 
rapidjson::Document text_to_document (const std::string &str)
 
template<typename Stream , typename Value >
Stream & to_stream (Stream &stream, const rapidjson::Value &v, const Value &k_true, const Value &k_false)
 
std::string to_string (const MapObject &map)
 
template<typename RapidJson >
std::string to_string (const RapidJson &v)
 

Typedef Documentation

◆ MapObject

using helper::json::MapObject = typedef std::map<std::string, std::string>

std::map that represents simple JSON object.

This type can hold only JSON Objects that consist only from string values, other types are going to be ignored or converted.

◆ Writer

template<typename T >
using helper::json::Writer = typedef rapidjson::Writer<T>

Function Documentation

◆ append_rapid_json_to_text()

template<template< typename > typename Writer = Writer, typename JsonValue >
void helper::json::append_rapid_json_to_text ( JsonValue json_value,
std::string &  text_value 
)

◆ array_iterator() [1/2]

auto helper::json::array_iterator ( const rapidjson::Value::ConstArray &  o)
inline

◆ array_iterator() [2/2]

auto helper::json::array_iterator ( rapidjson::Value::Array &  o)
inline

◆ member_iterator()

template<typename Obj >
auto helper::json::member_iterator ( Obj &  o)

◆ merge_objects() [1/2]

std::string helper::json::merge_objects ( const std::string &  j1,
const std::string &  j2,
const std::set< std::string > &  skip_attributes 
)

◆ merge_objects() [2/2]

std::optional< std::string > helper::json::merge_objects ( std::optional< std::string >  j1,
std::optional< std::string >  j2,
const std::set< std::string > &  skip_attributes 
)

◆ rapid_json_to_text()

template<template< typename > typename Writer = Writer, typename JsonValue >
void helper::json::rapid_json_to_text ( JsonValue json_value,
std::string &  text_value 
)

◆ text_to() [1/6]

template<typename Handler , typename Container >
bool helper::json::text_to ( Handler *  handler,
const Container &  c 
)

Convert text representation of json object/value to type defined by 'Handler'.

The 'Handler' must be a child class of rapidjson::BaseReaderHandler. The child class must contain type/alias definition of returned result, under "Result" alias and get_result method. For example:

class HandlerSomeExample
     : rapidjson::BaseReaderHandler<rapidjson::UTF8<>,HandlerSomeExample>

{ public: using Result = std::string;

    ...
 };

◆ text_to() [2/6]

bool helper::json::text_to ( rapidjson::Document *  doc,
const char *  str 
)
inline

◆ text_to() [3/6]

template<typename Container >
bool helper::json::text_to ( rapidjson::Document *  doc,
const Container &  c 
)

◆ text_to() [4/6]

bool helper::json::text_to ( rapidjson::Document *  doc,
const std::string &  str 
)
inline

◆ text_to() [5/6]

bool helper::json::text_to ( rapidjson::Document::Object *  obj,
const std::string &  str 
)
inline

◆ text_to() [6/6]

bool helper::json::text_to ( rapidjson::Value *  val,
const std::string &  str 
)
inline

◆ text_to_document()

rapidjson::Document helper::json::text_to_document ( const std::string &  str)
inline

◆ text_to_handler()

template<typename Handler , typename Container , typename... HandlerArgs>
Handler::Result helper::json::text_to_handler ( const Container &  c,
HandlerArgs &&...  args 
)

Convert text representation of json object/value to type defined by 'Handler'.

The 'Handler' must be a child class of rapidjson::BaseReaderHandler. The child class must contain type/alias definition of returned result, under "Result" alias and get_result method. For example:

class HandlerSomeExample
     : rapidjson::BaseReaderHandler<rapidjson::UTF8<>,HandlerSomeExample>

{ public: using Result = std::string;

    ...
 };

◆ to_bool() [1/2]

std::optional< bool > helper::json::to_bool ( const rapidjson::Value &  value)

◆ to_bool() [2/2]

std::optional< bool > helper::json::to_bool ( const std::string &  value)

◆ to_stream()

template<typename Stream , typename Value >
Stream & helper::json::to_stream ( Stream &  stream,
const rapidjson::Value &  v,
const Value &  k_true,
const Value &  k_false 
)

◆ to_string() [1/3]

std::string helper::json::to_string ( const MapObject map)

◆ to_string() [2/3]

template<typename RapidJson >
std::string helper::json::to_string ( const RapidJson &  v)

◆ to_string() [3/3]

std::string helper::json::to_string ( const rapidjson::Value &  value)
inline

◆ validate_json_with_schema()

bool helper::json::validate_json_with_schema ( const std::string &  json,
const std::string &  schema,
std::string *  error_description = nullptr 
)
inline