diff options
author | Ilya Zverev <zverik@textual.ru> | 2018-03-02 18:49:07 +0300 |
---|---|---|
committer | Tatiana Yan <tatiana.kondakova@gmail.com> | 2018-03-06 11:46:04 +0300 |
commit | 9d1b7686abeb36661e412cf6cace084d879b5430 (patch) | |
tree | bd83e8021657ef6a22b20e67f9f6e356a232d78e /3party | |
parent | 5bf92c7d4cbed3827c28cdb74ff5d4eef5f19e46 (diff) |
Extract addresses tool
Diffstat (limited to '3party')
-rw-r--r-- | 3party/jansson/myjansson.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/3party/jansson/myjansson.hpp b/3party/jansson/myjansson.hpp index 2129ed1818..cfeb2b35e7 100644 --- a/3party/jansson/myjansson.hpp +++ b/3party/jansson/myjansson.hpp @@ -108,11 +108,32 @@ inline my::JSONPtr ToJSON(bool value) { return my::NewJSONBool(value); } inline my::JSONPtr ToJSON(char const * s) { return my::NewJSONString(s); } template <typename T> +void ToJSONArray(json_t & root, T const & value) +{ + json_array_append_new(&root, ToJSON(value).release()); +} + +inline void ToJSONArray(json_t & parent, my::JSONPtr & child) +{ + json_array_append_new(&parent, child.release()); +} + +inline void ToJSONArray(json_t & parent, json_t & child) +{ + json_array_append_new(&parent, &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()); } +inline void ToJSONObject(json_t & parent, std::string const & field, my::JSONPtr & child) +{ + json_object_set_new(&parent, field.c_str(), child.release()); +} + inline void ToJSONObject(json_t & parent, std::string const & field, json_t & child) { json_object_set_new(&parent, field.c_str(), &child); |