summaryrefslogtreecommitdiff
path: root/src/codec-json/json.tmpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/codec-json/json.tmpl.h')
-rw-r--r--src/codec-json/json.tmpl.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/codec-json/json.tmpl.h b/src/codec-json/json.tmpl.h
index 4f4d6f4..4ef8676 100644
--- a/src/codec-json/json.tmpl.h
+++ b/src/codec-json/json.tmpl.h
@@ -391,7 +391,7 @@ struct json_decode<schema::Primitive<T,N>, RootSchema, ToDecode> {
template<typename RootSchema, typename ToDecode>
struct json_decode<schema::String, RootSchema, ToDecode> {
static error_or<void> decode(buffer_view& buff, data<schema::String, ToDecode>& to){
- assert(buff.read('"'));
+ assert(buff.read() == '"');
buff.read_advance(1);
std::stringstream iss;
@@ -493,9 +493,9 @@ struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> {
}
++index[Level];
- if(buff.read(',')){
+ if(buff.read() == ','){
buff.read_advance(1);
- } else if(buff.read(']')){
+ } else if(buff.read() == ']'){
buff.read_advance(1);
break;
} else {
@@ -516,9 +516,10 @@ struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> {
}
template<std::size_t Level>
- static error_or<void> decode_unflat_level(const std::vector<data<T,encode::Native>>& flat, data<schema::Array<T,D>, ToDecode>& to, std::array<std::size_t, D>& index, std::size_t& flat_index) {
+ static error_or<void> decode_unflat_level(std::vector<data<T,encode::Native>>& flat, data<schema::Array<T,D>, ToDecode>& to, std::array<std::size_t, D>& index, std::size_t& flat_index) {
if constexpr ( Level == D ){
- to.at(index) = flat.at(flat_index);
+ auto& flat_data = flat.at(flat_index);
+ to.at(index) = std::move(flat_data);
++flat_index;
}else {
const std::size_t dim_size = to.get_dim_size(Level);
@@ -530,6 +531,7 @@ struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> {
}
}
}
+ return void_t{};
}
static error_or<void> decode(buffer_view& buff, data<schema::Array<T,D>, ToDecode>& to){