Can now customise mapping by passing a function

This enables various scenarios like mapping Json or Xml into a type
richer than a string.