diff options
Diffstat (limited to 'modules/codec-json/c++/json.hpp')
| -rw-r--r-- | modules/codec-json/c++/json.hpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/modules/codec-json/c++/json.hpp b/modules/codec-json/c++/json.hpp index 1da74b1..a982bf3 100644 --- a/modules/codec-json/c++/json.hpp +++ b/modules/codec-json/c++/json.hpp @@ -66,6 +66,12 @@ struct codec_config<encode::Json> { uint64_t depth = 16u; uint64_t length = 4096u; bool pretty = false; + /** + * Strict decoding demands a fully described dataset. + * Every member of a Struct has to be present in the json data. + * Non strict decoding is the default, since configuration files + * usually only describe the deviations from the default values. + */ bool strict = false; bool is_within(uint64_t bytes, uint64_t d){ @@ -117,7 +123,7 @@ public: buffer_view buff_v{from_decode.get_buffer()}; impl::json_helper::skip_whitespace(buff_v); - auto eov = impl::json_decode<Schema, ToEncoding>::decode(buff_v, to_decode); + auto eov = impl::json_decode<Schema, ToEncoding>::decode(buff_v, to_decode, cfg_); if(eov.is_error()){ return std::move(eov.get_error()); } @@ -129,6 +135,15 @@ public: void set_pretty(bool pretty){ cfg_.pretty = pretty; } + + /** + * Strict decoding demands a fully described dataset. + * Non strict decoding allows missing struct members, which keep + * their default value in that case. + */ + void set_strict(bool strict){ + cfg_.strict = strict; + } }; } |
