0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::json: Fix value type LITERAL serialize/stringify consistency.

This commit is contained in:
Jason Volk 2018-03-21 15:43:35 -07:00
parent 502675e527
commit 0e7ef9ef7d

View file

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