diff options
author | Georg Brandl <georg@python.org> | 2007-08-09 19:22:20 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-08-09 19:22:20 +0000 |
commit | b1271fa623f77140d8a96e7e29514a4f75cf1a64 (patch) | |
tree | f38e10803f7ac5516039d23ddebdc70382cd49e4 /sphinx/util/json.py | |
parent | be36a0f85d5afb588466b5cec42465336bb37b3a (diff) | |
download | sphinx-git-b1271fa623f77140d8a96e7e29514a4f75cf1a64.tar.gz |
Fix searching and search index creation for incremental builds.
Diffstat (limited to 'sphinx/util/json.py')
-rw-r--r-- | sphinx/util/json.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sphinx/util/json.py b/sphinx/util/json.py index 99a0e5edb..c2436e518 100644 --- a/sphinx/util/json.py +++ b/sphinx/util/json.py @@ -16,7 +16,7 @@ import re -ESCAPE = re.compile(r'[\x00-\x19\\"\b\f\n\r\t]') +# escape \, ", control characters and everything outside ASCII ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])') ESCAPE_DICT = { '\\': '\\\\', @@ -27,8 +27,6 @@ ESCAPE_DICT = { '\r': '\\r', '\t': '\\t', } -for i in range(0x20): - ESCAPE_DICT.setdefault(chr(i), '\\u%04x' % (i,)) def encode_basestring_ascii(s): @@ -70,3 +68,11 @@ def dump_json(obj, key=False): elif isinstance(obj, basestring): return encode_basestring_ascii(obj) raise TypeError(type(obj)) + + +STRING = re.compile(r'("(\\\\|\\"|[^"])*")') + +def load_json(s): + d = {'null': None, 'true': True, 'false': False} + s = STRING.sub(r'u\1', s) + return eval(s, d) |