diff options
author | Maksim Andrianov <maksimandrianov1@gmail.com> | 2018-10-15 12:03:35 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-10-16 15:08:18 +0300 |
commit | 1501b9d3376d9927049d5cb2883116ab84c7232a (patch) | |
tree | c6bbd5af5bb0d43538705f45786b678b0e29f11b /3party | |
parent | 929f456d46a89c0d03258ad6b89063f594ccb2f2 (diff) |
[generator] Added empty houses processing.
Diffstat (limited to '3party')
-rw-r--r-- | 3party/jansson/myjansson.hpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/3party/jansson/myjansson.hpp b/3party/jansson/myjansson.hpp index 406def8eee..213021445d 100644 --- a/3party/jansson/myjansson.hpp +++ b/3party/jansson/myjansson.hpp @@ -131,19 +131,45 @@ inline void ToJSONArray(json_t & parent, json_t & child) } template <typename T> +void ToJSONObject(json_t & root, char const * field, T const & value) +{ + json_object_set_new(&root, field, ToJSON(value).release()); +} + +inline void ToJSONObject(json_t & parent, char const * field, base::JSONPtr && child) +{ + json_object_set_new(&parent, field, child.release()); +} + +inline void ToJSONObject(json_t & parent, char const * field, base::JSONPtr & child) +{ + json_object_set_new(&parent, field, child.release()); +} + +inline void ToJSONObject(json_t & parent, char const * field, json_t & child) +{ + json_object_set_new(&parent, field, &child); +} + +template <typename T> void ToJSONObject(json_t & root, std::string const & field, T const & value) { - json_object_set_new(&root, field.c_str(), ToJSON(value).release()); + ToJSONObject(root, field.c_str(), value); +} + +inline void ToJSONObject(json_t & parent, std::string const & field, base::JSONPtr && child) +{ + ToJSONObject(parent, field.c_str(), std::move(child)); } inline void ToJSONObject(json_t & parent, std::string const & field, base::JSONPtr & child) { - json_object_set_new(&parent, field.c_str(), child.release()); + ToJSONObject(parent, field.c_str(), child); } inline void ToJSONObject(json_t & parent, std::string const & field, json_t & child) { - json_object_set_new(&parent, field.c_str(), &child); + ToJSONObject(parent, field.c_str(), child); } template <typename T> @@ -183,12 +209,18 @@ bool FromJSONObjectOptional(json_t * root, std::string const & field, std::vecto } template <typename T> -void ToJSONObject(json_t & root, std::string const & field, std::vector<T> const & values) +void ToJSONObject(json_t & root, char const * field, std::vector<T> const & values) { auto arr = base::NewJSONArray(); for (auto const & value : values) json_array_append_new(arr.get(), ToJSON(value).release()); - json_object_set_new(&root, field.c_str(), arr.release()); + json_object_set_new(&root, field, arr.release()); +} + +template <typename T> +void ToJSONObject(json_t & root, std::string const & field, std::vector<T> const & values) +{ + ToJSONObject(root, field.c_str(), values); } template <typename T> |