Allow overring json codec in to_json()