diff options
Diffstat (limited to 'src/codec-json')
-rw-r--r-- | src/codec-json/json.tmpl.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/codec-json/json.tmpl.h b/src/codec-json/json.tmpl.h index 4ef8676..8fb01a9 100644 --- a/src/codec-json/json.tmpl.h +++ b/src/codec-json/json.tmpl.h @@ -459,14 +459,26 @@ struct json_decode<schema::String, RootSchema, ToDecode> { } }; -// The whole std::vector approach is hacky af +template<typename... T, string_literal... Lits, typename RootSchema, typename ToDecode> +struct json_decode<schema::Struct<schema::Member<T,Lits>...>, RootSchema, ToDecode> { + static error_or<void> decode(buffer_view& buff, data<schema::Struct<schema::Member<T,Lits>...>, ToDecode>& to){ + + return make_error<err::not_implemented>(); + } +}; + +// The whole std::vector approach is hacky af. ToDo change it maybe? template<typename T, size_t D, typename RootSchema, typename ToDecode> struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> { template<size_t Level> static error_or<void> decode_flat_level(buffer_view& buff, std::vector<data<T, encode::Native>>& to, std::array<std::size_t, D>& index, std::array<std::size_t, D>& dims, bool log_dim){ if constexpr (Level == D) { json_helper::skip_whitespace(buff); - to.push_back({}); + try { + to.push_back({}); + }catch(std::exception& e){ + return make_error<err::out_of_memory>(); + } auto eov = json_decode<T, RootSchema, ToDecode>::decode(buff, to.back()); if(eov.is_error()){ return eov; |