def truncate_fun(content, length): truncated = Payload._truncate_json(content, length) escaped = Payload._to_json_utf8(truncated)[1:-1] return context[0] + escaped + context[1]