The OpenD Programming Language

serializeValue

Enum serialization

Examples

import mir.ser.json: serializeJson;
import mir.ser.ion: serializeIon;
import mir.ser.text: serializeText;
import mir.deser.ion: deserializeIon;
import mir.small_string;
import mir.rc.array;
enum Key { bar, @serdeKeys("FOO", "foo") foo }
assert(serializeJson(Key.foo) == `"FOO"`);
assert(serializeText(Key.foo) == `FOO`);
assert(serializeIon(Key.foo).deserializeIon!Key == Key.foo);
assert(serializeIon(Key.foo).deserializeIon!string == "FOO");
assert(serializeIon(Key.foo).deserializeIon!(SmallString!32) == "FOO");
auto rcstring = serializeIon(Key.foo).deserializeIon!(RCArray!char);
assert(rcstring[] == "FOO");

Meta