deserializeValue

Deserializes string value. This function allocates new string.

Examples

String enums supports only enum keys

enum SimpleEnum : string
{
    @serdeKeys("se1", "se1value")
    se1 = "se1value",

    @serdeKeys("se2", "se2value")
    se2 = "se2value",

    @serdeKeys("se3", "se3value")
    se3 = "se3value",
}

struct Simple
{
    SimpleEnum en;
    SimpleEnum ex;
}

Simple simple = `{"en":"se2", "ex":"se3value"}`.deserialize!Simple;
assert(simple.en == SimpleEnum.se2);
assert(simple.ex == SimpleEnum.se3);

issue #115

import asdf;
import std.typecons;

struct Example
{
    @serdeOptional
    Nullable!string field1;
}

assert(`{}`.deserialize!Example == Example());
assert(Example().serializeToJson == `{"field1":null}`);
assert(deserialize!string(serializeToJson(null)) is null);
assert(deserialize!string(serializeToAsdf(null)) is null);
assert(deserialize!string(serializeToJson("\tbar")) == "\tbar");
assert(deserialize!string(serializeToAsdf("\"bar")) == "\"bar");

Meta