mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::json: Fix value type LITERAL serialize/stringify consistency.
This commit is contained in:
parent
502675e527
commit
0e7ef9ef7d
1 changed files with 15 additions and 2 deletions
17
ircd/json.cc
17
ircd/json.cc
|
@ -1573,7 +1573,13 @@ ircd::json::stringify(mutable_buffer &buf,
|
|||
|
||||
case LITERAL:
|
||||
{
|
||||
printer(buf, printer.literal, string_view{v});
|
||||
if(v.serial)
|
||||
printer(buf, printer.literal, string_view{v});
|
||||
else if(v.integer)
|
||||
consume(buf, copy(buf, "true"_sv));
|
||||
else
|
||||
consume(buf, copy(buf, "false"_sv));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1660,7 +1666,14 @@ ircd::json::serialized(const value &v)
|
|||
return v.serial? serialized(json::array{v}) : serialized(v.array, v.array + v.len);
|
||||
|
||||
case LITERAL:
|
||||
return v.serial? v.len : serialized(bool(v.integer));
|
||||
{
|
||||
if(v.serial)
|
||||
return v.len;
|
||||
else if(v.integer)
|
||||
return size("true"_sv);
|
||||
else
|
||||
return size("false"_sv);
|
||||
}
|
||||
|
||||
case NUMBER:
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue