0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 00:02:34 +01:00

ircd::json: Add overload to insert multiple members.

This commit is contained in:
Jason Volk 2023-04-18 19:39:08 -07:00
parent a10992b813
commit 22b9cf515c
2 changed files with 12 additions and 2 deletions

View file

@ -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});
}

View file

@ -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