mirror of
https://github.com/matrix-construct/construct
synced 2024-11-10 20:11:07 +01:00
ircd::json: Add overload to insert multiple members.
This commit is contained in:
parent
a10992b813
commit
22b9cf515c
2 changed files with 12 additions and 2 deletions
|
@ -22,8 +22,16 @@ namespace ircd::json
|
|||
strung remove(const object &, const string_view &key);
|
||||
strung remove(const object &, const size_t &index);
|
||||
|
||||
strung insert(const object &, const members &);
|
||||
strung insert(const object &, const member &);
|
||||
|
||||
strung replace(const object &, const members &);
|
||||
strung replace(const object &, const member &);
|
||||
}
|
||||
|
||||
inline ircd::json::strung
|
||||
ircd::json::insert(const object &s,
|
||||
const json::member &m)
|
||||
{
|
||||
return insert(s, json::members{m});
|
||||
}
|
||||
|
|
|
@ -660,7 +660,7 @@ ircd::json::replace(const object &s,
|
|||
|
||||
ircd::json::strung
|
||||
ircd::json::insert(const object &s,
|
||||
const json::member &m)
|
||||
const json::members &m)
|
||||
{
|
||||
if(unlikely(!empty(s) && type(s) != type::OBJECT))
|
||||
throw type_error
|
||||
|
@ -674,7 +674,9 @@ ircd::json::insert(const object &s,
|
|||
for(const object::member &m : object{s})
|
||||
mb.at(mctr++) = member{m};
|
||||
|
||||
mb.at(mctr++) = m;
|
||||
for(const auto &_m : m)
|
||||
mb.at(mctr++) = _m;
|
||||
|
||||
return strung
|
||||
{
|
||||
mb.data(), mb.data() + mctr
|
||||
|
|
Loading…
Reference in a new issue