Note that there is a convenience function dutils.data.json.serializeToJSON that can be used instead of manually invoking serialize.
import dutils.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");
dutils.data.json.JSONSerializer, dutils.data.json.JSONStringSerializer, dutils.data.bson.BsonSerializer
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.