vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Function serialize

Serializes a value with the given serializer.

auto serialize(Serializer, T, ARGS...) (
  auto ref T value,
  ARGS args

void serialize(Serializer, T) (
  ref Serializer serializer,
  auto ref T value

The serializer must have a value result for the first form to work. Otherwise, use the range based form.

See Also

JsonSerializer, JsonStringSerializer, BsonSerializer


Note that there is a convenience function serializeToJson that can be used instead of manually invoking serialize.


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");

Sönke Ludwig


© 2013-2016 rejectedsoftware e.K.


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.