Allow custom JSON encoding options

Allow the caller to provide additional options to `json_encode`