mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::json: Fix and optimize for loss of type on member property names.
This commit is contained in:
parent
ad3fedd2e2
commit
57d2cc9350
1 changed files with 8 additions and 4 deletions
12
ircd/json.cc
12
ircd/json.cc
|
@ -2550,7 +2550,10 @@ ircd::json::stringify(mutable_buffer &buf,
|
||||||
const object::member &member)
|
const object::member &member)
|
||||||
{
|
{
|
||||||
char *const start(begin(buf));
|
char *const start(begin(buf));
|
||||||
printer(buf, printer.name << printer.name_sep, member.first);
|
assert(!surrounds(member.first, '"'));
|
||||||
|
consume(buf, copy(buf, "\""_sv));
|
||||||
|
consume(buf, copy(buf, member.first));
|
||||||
|
consume(buf, copy(buf, "\":"_sv));
|
||||||
stringify(buf, member.second);
|
stringify(buf, member.second);
|
||||||
const string_view ret
|
const string_view ret
|
||||||
{
|
{
|
||||||
|
@ -2564,8 +2567,7 @@ ircd::json::stringify(mutable_buffer &buf,
|
||||||
size_t
|
size_t
|
||||||
ircd::json::serialized(const object::member &member)
|
ircd::json::serialized(const object::member &member)
|
||||||
{
|
{
|
||||||
const json::value key{member.first, json::STRING};
|
return 1 + size(member.first) + 1 + 1 + serialized(member.second);
|
||||||
return serialized(key) + 1 + serialized(member.second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
|
@ -3022,7 +3024,9 @@ try
|
||||||
{
|
{
|
||||||
[](mutable_buffer &buf, const member *const &m)
|
[](mutable_buffer &buf, const member *const &m)
|
||||||
{
|
{
|
||||||
printer(buf, printer.name << printer.name_sep, m->first);
|
assert(type(m->first) == STRING);
|
||||||
|
stringify(buf, m->first);
|
||||||
|
printer(buf, printer.name_sep);
|
||||||
stringify(buf, m->second);
|
stringify(buf, m->second);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue