Return a JSON representation of a Python string
(s)
| 34 | FLOAT_REPR = repr |
| 35 | |
| 36 | def encode_basestring(s): |
| 37 | """Return a JSON representation of a Python string |
| 38 | |
| 39 | """ |
| 40 | if isinstance(s, str) and HAS_UTF8.search(s) is not None: |
| 41 | s = s.decode('utf-8') |
| 42 | def replace(match): |
| 43 | return ESCAPE_DCT[match.group(0)] |
| 44 | return u'"' + ESCAPE.sub(replace, s) + u'"' |
| 45 | |
| 46 | |
| 47 | def py_encode_basestring_ascii(s): |