From 0500d4347a6d31ef05fd860559e380c2e488c194 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 4 May 2022 16:28:12 -0400 Subject: JSON: add blob type that generates base64-encoded binary data --- libtests/json.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libtests') diff --git a/libtests/json.cc b/libtests/json.cc index 3844222f..b386e6eb 100644 --- a/libtests/json.cc +++ b/libtests/json.cc @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -113,6 +114,19 @@ test_main() {"c", "[\n true\n]"}, }; assert(dvalue == xdvalue); + auto blob_data = [](Pipeline* p) { + *p << "\x01\x02\x03\x04\x05\xff\xfe\xfd\xfc\xfb"; + }; + JSON jblob = JSON::makeDictionary(); + jblob.addDictionaryMember("normal", JSON::parse(R"("string")")); + jblob.addDictionaryMember("blob", JSON::makeBlob(blob_data)); + // cSpell:ignore AQIDBAX + check( + jblob, + "{\n" + " \"blob\": \"AQIDBAX//v38+w==\",\n" + " \"normal\": \"string\"\n" + "}"); } static void -- cgit v1.2.3-54-g00ecf