JSON Voorhees
Killer JSON for C++
Serialization: Enum Adapter

Create an adapter with the specified mapping values.

Parameters
enum_nameA user-friendly name for this enumeration to be used in error messages.
mappingA list of C++ types and values to use in to_json and extract. It is okay to have a C++ value with more than one JSON representation. In this case, the first JSON representation will be used in to_json, but all JSON representations will be interpreted as the C++ value. It is also okay to have the same JSON representation for multiple C++ values. In this case, the first JSON representation provided for that value will be used in extract.
enum_adapter<ring>("ring",
{
{ ring::fire, "fire" },
{ ring::wind, "wind" },
{ ring::earth, "earth" },
{ ring::water, "water" },
{ ring::heart, "heart" }, // "heart" is preferred for to_json
{ ring::heart, "useless" }, // "useless" is interpreted as ring::heart in extract
}
);

: Enum Adapter