1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-31 10:24:23 +03:00

Extend type_name() to invalid type (#4786)

*  add regression test

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 💚 fix build

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 📝 add comment

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2025-05-16 18:16:47 +02:00
committed by GitHub
parent 46e7cd3dc2
commit 828c891427
3 changed files with 20 additions and 4 deletions

View File

@ -563,7 +563,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
(t == value_t::binary && binary == nullptr)
)
{
//not initialized (e.g., due to exception in the ctor)
// not initialized (e.g., due to exception in the ctor)
return;
}
if (t == value_t::array || t == value_t::object)
@ -4206,8 +4206,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
default:
return "number";
default:
return "invalid";
}
}