Skip to content

Commit

Permalink
ready to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Oct 26, 2023
1 parent 3d8c0fb commit 97105bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions include/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ class basic_value
template <typename... args_t>
basic_value(value_type type, args_t&&... args);

// Prohibit conversion of other types to basic_value
template <typename value_t, typename _ = std::enable_if_t<!std::is_convertible_v<value_t, basic_value<string_t>>>>
basic_value(value_t) = delete;

// I don't know if you want to convert char to string or number, so I delete these constructors.
basic_value(char) = delete;
basic_value(unsigned char) = delete;
basic_value(wchar_t) = delete;
basic_value(char16_t) = delete;
basic_value(char32_t) = delete;
basic_value(wchar_t) = delete;

~basic_value();

Expand Down
4 changes: 2 additions & 2 deletions sample/sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ bool serializing()
{ { "i", "am", "key1" }, { { 1, { 0.1, 0.2 } }, { 2, { 0.2, 0.3 } } } },
{ { "key2" }, { { 3, { 0.4 } }, { 4, { 0.5, 0.6, 0.7 } } } },
};
// the "std::map<int, xxx>" cannot be converted to json because the key is "int",
// the "std::map" cannot be converted to json because the key is "std::vector<std::string>",
// you can set the template parameter "loose" of "serialize" to true, which will make a more relaxed conversion.
json::value crazy_serialization = json::serialize<true>(more_complex);
root["more_complex"] = json::serialize<true>(more_complex);

// for test
root["a\\n"] = "1a\\n";
Expand Down

0 comments on commit 97105bd

Please sign in to comment.