Add char8_t* overload for _json and _json_pointer (#4963)

This commit is contained in:
Niels Lohmann
2025-10-25 07:56:05 +02:00
committed by GitHub
parent df263544ed
commit 29913ca760
6 changed files with 94 additions and 0 deletions

View File

@@ -25402,6 +25402,15 @@ JSON_HEDLEY_NON_NULL(1)
return nlohmann::json::parse(s, s + n);
}
#if defined(__cpp_char8_t)
JSON_HEDLEY_NON_NULL(1)
inline nlohmann::json operator""_json(const char8_t* s, std::size_t n)
{
return nlohmann::json::parse(reinterpret_cast<const char*>(s),
reinterpret_cast<const char*>(s) + n);
}
#endif
/// @brief user-defined string literal for JSON pointer
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/
JSON_HEDLEY_NON_NULL(1)
@@ -25415,6 +25424,13 @@ JSON_HEDLEY_NON_NULL(1)
return nlohmann::json::json_pointer(std::string(s, n));
}
#if defined(__cpp_char8_t)
inline nlohmann::json::json_pointer operator""_json_pointer(const char8_t* s, std::size_t n)
{
return nlohmann::json::json_pointer(std::string(reinterpret_cast<const char*>(s), n));
}
#endif
} // namespace json_literals
} // namespace literals
NLOHMANN_JSON_NAMESPACE_END