def escape_string_json(st):
ret = []<EOL>c = <NUM_LIT:0><EOL>ln = len(st)<EOL>escape_chmap = {<EOL>b'<STR_LIT>': b'<STR_LIT:b>',<EOL>b'<STR_LIT>': b'<STR_LIT:f>',<EOL>b'<STR_LIT:\n>': b'<STR_LIT:n>',<EOL>b'<STR_LIT:\r>': b'<STR_LIT:r>',<EOL>b'<STR_LIT:\t>': b'<STR_LIT:t>',<EOL>b'<STR_LIT:\\>': b'<STR_LIT:\\>',<EOL>b'<STR_LIT>': b'<STR_LIT:">',<EOL>b'<STR_LIT>': b'<STR_LIT:/>'<EOL>}<EOL>while c < ln:<EOL><INDENT>ch = st[c:c+<NUM_LIT:1>]<EOL>if ch in escape_chmap:<EOL><INDENT>ret.append(b'<STR_LIT:\\>' + escape_chmap[ch])<EOL><DEDENT>elif ord(ch) < <NUM_LIT>:<EOL><INDENT>ret.append(b'<STR_LIT>' % ord(ch))<EOL><DEDENT>else:<EOL><INDENT>ret.append(ch)<EOL><DEDENT>c += <NUM_LIT:1><EOL><DEDENT>return b'<STR_LIT>'.join(ret)<EOL>
Escaping string for json
/Users/dusanklinec/workspace/monero/external/rapidjson/writer.h
:param st:
:return: