Unverified Commit a10d486e authored by Niels Lohmann's avatar Niels Lohmann Committed by GitHub

Merge pull request #2244 from matthewbauer/tag-cbor

Tag binary values in cbor if set
parents e65cc9dc dd08f770
......@@ -279,6 +279,12 @@ class binary_writer
case value_t::binary:
{
if (j.m_value.binary->has_subtype())
{
write_number(static_cast<std::uint8_t>(0xd8));
write_number(j.m_value.binary->subtype());
}
// step 1: write control byte and the binary array size
const auto N = j.m_value.binary->size();
if (N <= 0x17)
......
......@@ -12795,6 +12795,12 @@ class binary_writer
case value_t::binary:
{
if (j.m_value.binary->has_subtype())
{
write_number(static_cast<std::uint8_t>(0xd8));
write_number(j.m_value.binary->subtype());
}
// step 1: write control byte and the binary array size
const auto N = j.m_value.binary->size();
if (N <= 0x17)
......
......@@ -2503,6 +2503,8 @@ TEST_CASE("examples from RFC 7049 Appendix A")
std::vector<uint8_t> expected((std::istreambuf_iterator<char>(f_bin)),
std::istreambuf_iterator<char>());
CHECK(j == json::binary(expected));
CHECK(json::to_cbor(json::binary(std::vector<uint8_t> {}, 0x42)) == std::vector<uint8_t> {0xd8, 0x42, 0x40});
}
SECTION("arrays")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment