The OpenD Programming Language

deserializeJSON

Deserializes a JSONValue to T

@safe
T
deserializeJSON
(
T
)
(
auto ref JSONValue root
)

Throws

SerializationException if fails to create an instance of any class SerializationException if a jsonRequired serializable is missing

Examples

immutable json = `{"a": 123, "b": "Hello"}`;

struct Test
{
    @serializable int a;
    @serializable string b;
}

immutable test = deserializeJSON!Test(parseJSON(json));
assert(test.a == 123 && test.b == "Hello");

Meta