1
0
mirror of https://github.com/nlohmann/json synced 2024-11-23 12:30:06 +00:00

support enum

construct enum type to basic_json (proxy by int type)
```
    enum { t = 0 };
    json  j = json::array();
    j.push_back(t);

    j.push_back(json::object({
         {"game_type", t}
    }));
```
This commit is contained in:
易思龙 2015-05-09 17:44:10 +08:00
parent 9f9d293bad
commit 91aee10579

View File

@ -417,6 +417,11 @@ class basic_json
inline basic_json(const number_integer_t& value)
: m_type(value_t::number_integer), m_value(value)
{}
/// create an int number to support enum type (implicit)
inline basic_json(int int_enum)
: m_type(value_t::number_integer), m_value((NumberIntegerType)int_enum)
{}
/// create an integer number (implicit)
template<typename T, typename