@classmethod<EOL><INDENT>def encode(cls, value):<DEDENT>
try:<EOL><INDENT>coerced = dict(value)<EOL>if coerced == value:<EOL><INDENT>return json.dumps(coerced).encode(cls._encoding)<EOL><DEDENT><DEDENT>except (TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT>raise InvalidValue('<STR_LIT>')<EOL>
encode the dict as a json string to be written into redis.

:param value: dict
:return: bytes