Template Class serializer

Class Documentation

template<typename BasicJsonType>
class serializer

Public Functions

inline serializer(output_adapter_t<char> s, const char ichar, error_handler_t error_handler_ = error_handler_t::strict)
Parameters:
  • s[in] output stream to serialize to

  • ichar[in] indentation character to use

  • error_handler_[in] how to react on decoding errors

serializer(const serializer&) = delete
serializer &operator=(const serializer&) = delete
serializer(serializer&&) = delete
serializer &operator=(serializer&&) = delete
~serializer() = default
inline void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent = 0)

internal implementation of the serialization function

This function is called by the public member function dump and organizes the serialization internally. The indentation level is propagated as additional parameter. In case of arrays and objects, the function is called recursively.

  • strings and object keys are escaped using escape_string()

  • integer numbers are converted implicitly via operator<<

  • floating-point numbers are converted to a string using "%g" format

Parameters:
  • val[in] value to serialize

  • pretty_print[in] whether the output shall be pretty-printed

  • indent_step[in] the indent level

  • current_indent[in] the current indent level (only used internally)

inline serializer(output_adapter_t<char> s, const char ichar, error_handler_t error_handler_ = error_handler_t::strict)
Parameters:
  • s[in] output stream to serialize to

  • ichar[in] indentation character to use

  • error_handler_[in] how to react on decoding errors

serializer(const serializer&) = delete
serializer &operator=(const serializer&) = delete
serializer(serializer&&) = delete
serializer &operator=(serializer&&) = delete
~serializer() = default
inline void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent = 0)

internal implementation of the serialization function

This function is called by the public member function dump and organizes the serialization internally. The indentation level is propagated as additional parameter. In case of arrays and objects, the function is called recursively.

  • strings and object keys are escaped using escape_string()

  • integer numbers are converted implicitly via operator<<

  • floating-point numbers are converted to a string using "%g" format

  • binary values are serialized as objects containing the subtype and the byte array

Parameters:
  • val[in] value to serialize

  • pretty_print[in] whether the output shall be pretty-printed

  • ensure_ascii[in] If ensure_ascii is true, all non-ASCII characters in the output are escaped with \uXXXX sequences, and the result consists of ASCII characters only.

  • indent_step[in] the indent level

  • current_indent[in] the current indent level (only used internally)