# Utils.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/parser/json/Utils.hpp"

# Utils

Utility class for json serializer/deserializer. Used by oatpp::parser::json::mapping::Serializer, oatpp::parser::json::mapping::Deserializer.

namespace oatpp { namespace parser { namespace json { 
  class Utils {}
}}}

# Fields

Type Name Summary
v_int64 ERROR_CODE_INVALID_ESCAPED_CHAR ERROR_CODE_INVALID_ESCAPED_CHAR
v_int64 ERROR_CODE_INVALID_SURROGATE_PAIR ERROR_CODE_INVALID_SURROGATE_PAIR
v_int64 ERROR_CODE_PARSER_QUOTE_EXPECTED '\' - EXPECTED" ERROR_CODE_PARSER_QUOTE_EXPECTED

# Methods

Return Type Name Summary
String escapeString Escape string as for json standard.
String unescapeString Unescape string as for json standard.
std::string unescapeStringToStdString Same as Utils::unescapeString() but return std::string.
String parseString Parse string enclosed in "<string>".
std::string parseStringToStdString Parse string enclosed in "<string>".

# Utils::ERROR_CODE_INVALID_ESCAPED_CHAR

ERROR_CODE_INVALID_ESCAPED_CHAR

static constexpr v_int64 ERROR_CODE_INVALID_ESCAPED_CHAR = 1

# Utils::ERROR_CODE_INVALID_SURROGATE_PAIR

ERROR_CODE_INVALID_SURROGATE_PAIR

static constexpr v_int64 ERROR_CODE_INVALID_SURROGATE_PAIR = 2

# Utils::ERROR_CODE_PARSER_QUOTE_EXPECTED

'\' - EXPECTED" ERROR_CODE_PARSER_QUOTE_EXPECTED

static constexpr v_int64 ERROR_CODE_PARSER_QUOTE_EXPECTED = 3

# Utils::escapeString

Escape string as for json standard.
Note: if(copyAsOwnData == false escapedString == initialString) then result string will point to initial data.

  • @param data - pointer to string to escape.
  • @param size - data size.
  • @param flags - escape flags.
  • @return - oatpp::String.

static String escapeString(const char* data, v_buff_size size, v_uint32 flags = FLAG_ESCAPE_ALL)

# Utils::unescapeString

Unescape string as for json standard.

static String unescapeString(const char* data, v_buff_size size, v_int64& errorCode, v_buff_size& errorPosition)

# Utils::unescapeStringToStdString

Same as Utils::unescapeString() but return std::string.

static std::string unescapeStringToStdString(const char* data, v_buff_size size, v_int64& errorCode, v_buff_size& errorPosition)

# Utils::parseString

Parse string enclosed in "<string>".

static String parseString(ParsingCaret& caret)

# Utils::parseStringToStdString

Parse string enclosed in "<string>".

static std::string parseStringToStdString(ParsingCaret& caret)