We added the policy parameter to all deserializeImpl methods. This allows users to customize deserialization for any specific type, while the remaining types can still use the module-level deserializeImpl method via UFCS.
deserializeImpl is like:
void deserializeImpl(P, T, JT)(ref P policy, ref JT tokenizer, ref T item) if (type constrains) {....}
An example of customized policy is like:
static struct DTStringPolicy {
void deserializeImpl(JT, T)(ref JT tokenizer, ref T item) {
static if (is(T == DateTime))
{
// Deserialize DateTime from a string
auto jsonItem = tokenizer.nextSignificant
.jsonExpect(JSONToken.String, "Parsing DateTime");
item = DateTime.fromSimpleString(extractString!string(jsonItem, tokenizer.chain));
}
else {
// default to module behavior
.deserializeImpl(this, tokenizer, item);
};
}
}
https://github.com/schveiguy/jsoniopipe/pull/51
https://github.com/schveiguy/jsoniopipe/pull/52