Function serialize
Serializes a value
with the given serializer
.
The serializer
must have a value
result for the first form
to work. Otherwise, use the range based form.
Prototypes
auto serialize(Serializer, T, ARGS...)(
T value,
ARGS args
);
void serialize(Serializer, T)(
ref Serializer serializer,
T value
);
See Also
vibe.data.json.JsonSerializer
,
vibe.data.json.JsonStringSerializer
,
vibe.data.bson.BsonSerializer
Example
Note that there is a convenience function vibe.data.json.serializeToJson
that can be used instead of manually invoking serialize
.
import vibe .data .json;
struct Test {
int value;
string text;
}
Test test;
test .value = 12;
test .text = "Hello";
Json serialized = serialize!JsonSerializer(test);
assert(serialized .value .get!int == 12);
assert(serialized .text .get!string == "Hello");
Authors
Sönke Ludwig
Copyright
© 2013-2014 rejectedsoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.