template<typename BasicJsonType>
class nlohmann::detail::serializer< BasicJsonType >
Definition at line 12035 of file json.hpp.
template<typename BasicJsonType >
static std::uint8_t nlohmann::detail::serializer< BasicJsonType >::decode |
( |
std::uint8_t & |
state, |
|
|
std::uint32_t & |
codep, |
|
|
const std::uint8_t |
byte |
|
) |
| |
|
inlinestaticprivatenoexcept |
check whether a string is UTF-8 encoded
The function checks each byte of a string whether it is UTF-8 encoded. The result of the check is stored in the state parameter. The function must be called initially with state 0 (accept). State 1 means the string must be rejected, because the current byte is not allowed. If the string is completely processed, but the state is non-zero, the string ended prematurely; that is, the last byte indicated more bytes should have followed.
- Parameters
-
[in,out] | state | the state of the decoding |
[in,out] | codep | codepoint (valid only if resulting state is UTF8_ACCEPT) |
[in] | byte | next byte to decode |
- Returns
- new state
- Note
- The function has been edited: a std::array is used.
- Copyright
- Copyright (c) 2008-2009 Bjoern Hoehrmann bjoer.nosp@m.n@ho.nosp@m.ehrma.nosp@m.nn.d.nosp@m.e
- See also
- http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
Definition at line 12775 of file json.hpp.
template<typename BasicJsonType >
void nlohmann::detail::serializer< BasicJsonType >::dump |
( |
const BasicJsonType & |
val, |
|
|
const bool |
pretty_print, |
|
|
const bool |
ensure_ascii, |
|
|
const unsigned int |
indent_step, |
|
|
const unsigned int |
current_indent = 0 |
|
) |
| |
|
inline |
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
-
[in] | val | value to serialize |
[in] | pretty_print | whether the output shall be pretty-printed |
[in] | indent_step | the indent level |
[in] | current_indent | the current indent level (only used internally) |
Definition at line 12085 of file json.hpp.
template<typename BasicJsonType >
dump escaped string
Escape a string by replacing certain special characters by a sequence of an escape character (backslash) and another character and other control characters by a sequence of "\u" followed by a four-digit hex representation. The escaped string is written to output stream o.
- Parameters
-
[in] | s | the string to escape |
[in] | ensure_ascii | whether to escape non-ASCII characters with \uXXXX sequences |
@complexity Linear in the length of string s.
Definition at line 12295 of file json.hpp.