1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

AK+LibIPC: Add a convenience encoder/decoder for JsonValue

This requires that JsonValue is implicitly default-constructible.
This commit is contained in:
Timothy Flynn 2022-11-07 16:30:55 -05:00 committed by Tim Flynn
parent 08750f69e4
commit 3994a79718
5 changed files with 21 additions and 1 deletions

View file

@ -7,6 +7,8 @@
#include <AK/BitCast.h>
#include <AK/ByteBuffer.h>
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <LibCore/AnonymousBuffer.h>
@ -159,6 +161,12 @@ Encoder& Encoder::operator<<(ByteBuffer const& value)
return *this;
}
Encoder& Encoder::operator<<(JsonValue const& value)
{
*this << value.serialized<StringBuilder>();
return *this;
}
Encoder& Encoder::operator<<(URL const& value)
{
return *this << value.to_string();