fixed #101
This commit is contained in:
parent
abd741708d
commit
82a6995306
3 changed files with 14 additions and 2 deletions
|
@ -3978,7 +3978,7 @@ class basic_json
|
||||||
{
|
{
|
||||||
// control characters (everything between 0x00 and 0x1f)
|
// control characters (everything between 0x00 and 0x1f)
|
||||||
// -> create four-digit hex representation
|
// -> create four-digit hex representation
|
||||||
o << "\\u" << std::hex << std::setw(4) << std::setfill('0') << int(c);
|
o << "\\u" << std::hex << std::setw(4) << std::setfill('0') << int(c) << std::dec;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -3978,7 +3978,7 @@ class basic_json
|
||||||
{
|
{
|
||||||
// control characters (everything between 0x00 and 0x1f)
|
// control characters (everything between 0x00 and 0x1f)
|
||||||
// -> create four-digit hex representation
|
// -> create four-digit hex representation
|
||||||
o << "\\u" << std::hex << std::setw(4) << std::setfill('0') << int(c);
|
o << "\\u" << std::hex << std::setw(4) << std::setfill('0') << int(c) << std::dec;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -9276,4 +9276,16 @@ TEST_CASE("regression tests")
|
||||||
// we need to cast to int to compile with Catch - the value is int32_t
|
// we need to cast to int to compile with Catch - the value is int32_t
|
||||||
CHECK(static_cast<int>(j["int_1"]) == 1);
|
CHECK(static_cast<int>(j["int_1"]) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("issue #101 - binary string causes numbers to be dumped as hex")
|
||||||
|
{
|
||||||
|
int64_t number = 10;
|
||||||
|
std::string bytes{"\x00" "asdf\n", 6};
|
||||||
|
json j;
|
||||||
|
j["int64"] = number;
|
||||||
|
j["binary string"] = bytes;
|
||||||
|
// make sure the number is really printed as decimal "10" and not as
|
||||||
|
// hexadecimal "a"
|
||||||
|
CHECK(j.dump() == "{\"binary string\":\"\\u0000asdf\\n\",\"int64\":10}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue