1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

CIParser: Make property headers human-readable in getMessageDescription

This commit is contained in:
reuk 2024-01-08 13:34:42 +00:00
parent 9a55eb852a
commit 0192c86715
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -162,7 +162,29 @@ private:
{
const auto opts = ToVarOptions{}.withExplicitVersion ((int) msg->header.version)
.withVersionIncluded (false);
const auto json = ToVar::convert (body, opts);
auto json = ToVar::convert (body, opts);
if (auto* obj = json->getDynamicObject(); obj != nullptr && obj->hasProperty ("header"))
{
const auto header = obj->getProperty ("header");
const auto bytes = [&]() -> std::vector<std::byte>
{
const auto* arr = header.getArray();
if (arr == nullptr)
return {};
std::vector<std::byte> vec;
vec.reserve ((size_t) arr->size());
for (const auto& i : *arr)
vec.push_back ((std::byte) (int) i);
return vec;
}();
obj->setProperty ("header", Encodings::jsonFrom7BitText (bytes));
}
if (json.has_value())
*result = String (getDescription (body)) + ": " + JSON::toString (*json, JSON::FormatOptions{}.withSpacing (JSON::Spacing::none));