Add json_encoder to json_encode

Allows to write custom JSONEncoders.