mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-02 16:16:19 +08:00
Json read string view (#312)
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <string>
|
#include <string_view>
|
||||||
|
|
||||||
#include "../Processors.hpp"
|
#include "../Processors.hpp"
|
||||||
#include "../internal/wrap_in_rfl_array_t.hpp"
|
#include "../internal/wrap_in_rfl_array_t.hpp"
|
||||||
@@ -30,8 +30,8 @@ auto read(const InputVarType& _obj) {
|
|||||||
|
|
||||||
/// Parses an object from JSON using reflection.
|
/// Parses an object from JSON using reflection.
|
||||||
template <class T, class... Ps>
|
template <class T, class... Ps>
|
||||||
Result<internal::wrap_in_rfl_array_t<T>> read(const std::string& _json_str) {
|
Result<internal::wrap_in_rfl_array_t<T>> read(std::string_view const _json_str) {
|
||||||
yyjson_doc* doc = yyjson_read(_json_str.c_str(), _json_str.size(), 0);
|
yyjson_doc* doc = yyjson_read(_json_str.data(), _json_str.size(), 0);
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
return Error("Could not parse document");
|
return Error("Could not parse document");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user