Marshall is a binary protocol, i.e. a bunch of bytes with very custom interpretation. It's not text, it doesn't conform to in any particular text encoding. It is, for the most part, just a sequence of bits. If you absolutely need to embed those in a text protocol like JSON, you need to escape the bytes that don't make valid characters in the relevant encoding (to be safe, assume a subset of ASCII). The canonical solution is base64:
import base64
code_string = marshal.dumps(fi.func_code)
code_base64 = base64.b64encode(code_string)
jsn = {"code": code_base64}