Function serializeWithPolicy

Serializes a value with the given serializer, representing values according to Policy when possible.

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

Prototypes

auto serializeWithPolicy(Serializer, alias Policy, T, ARGS...)(
  T value,
  ARGS args
);

void serializeWithPolicy(Serializer, alias Policy, T)(
  ref Serializer serializer,
  T value
);

See Also

vibe.data.json.JsonSerializer, vibe.data.json.JsonStringSerializer, vibe.data.bson.BsonSerializer

Example

import vibe.data.json;

static struct SizeI {
	int x;
	int y;
}
SizeI sizeI = SizeI(1,2);
Json serializedI = serializeWithPolicy!(JsonSerializer, SizePol)(sizeI);
assert(serializedI.get!string == "1x2");

static struct SizeF {
	float x;
	float y;
}
SizeF sizeF = SizeF(0.1f,0.2f);
Json serializedF = serializeWithPolicy!(JsonSerializer, SizePol)(sizeF);
assert(serializedF.get!string == "0.1x0.2");

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.