Lines Matching +full:end +full:- +full:to +full:- +full:end
20 return nan, inf, -inf
30 colno = pos - doc.rindex('\n', 0, pos)
34 def errmsg(msg, doc, pos, end=None): argument
37 if end is None:
42 endlineno, endcolno = linecol(doc, end)
43 fmt = '{0}: line {1} column {2} - line {3} column {4} (char {5} - {6})'
44 return fmt.format(msg, lineno, colno, endlineno, endcolno, pos, end)
45 #fmt = '%s: line %d column %d - line %d column %d (char %d - %d)'
46 #return fmt % (msg, lineno, colno, endlineno, endcolno, pos, end)
50 '-Infinity': NegInf,
55 STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
61 DEFAULT_ENCODING = "utf-8"
73 def py_scanstring(s, end, encoding=None, strict=True, argument
75 """Scan the string s for a JSON string. End is the index of the
78 on attempt to decode an invalid string. If strict is False then literal
82 after the end quote."""
87 begin = end - 1
89 chunk = _m(s, end)
93 end = chunk.end()
100 # Terminator is the end of string, a literal control character,
108 raise ValueError(errmsg(msg, s, end))
113 esc = s[end]
123 raise ValueError(errmsg(msg, s, end))
124 end += 1
127 uni = _decode_uXXXX(s, end)
128 end += 5
129 # Check for surrogate pair on UCS-4 systems
131 0xd800 <= uni <= 0xdbff and s[end:end + 2] == '\\u':
132 uni2 = _decode_uXXXX(s, end + 1)
134 uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
135 end += 6
139 return u''.join(chunks), end
150 s, end = s_and_end
153 # Use a slice to prevent IndexError from being raised, the following
155 nextchar = s[end:end + 1]
159 end = _w(s, end).end()
160 nextchar = s[end:end + 1]
165 return result, end + 1
169 return pairs, end + 1
172 "Expecting property name enclosed in double quotes", s, end))
173 end += 1
175 key, end = scanstring(s, end, encoding, strict)
177 # To skip some function call overhead we optimize the fast paths where
179 if s[end:end + 1] != ':':
180 end = _w(s, end).end()
181 if s[end:end + 1] != ':':
182 raise ValueError(errmsg("Expecting ':' delimiter", s, end))
183 end += 1
186 if s[end] in _ws:
187 end += 1
188 if s[end] in _ws:
189 end = _w(s, end + 1).end()
194 value, end = scan_once(s, end)
196 raise ValueError(errmsg("Expecting object", s, end))
200 nextchar = s[end]
202 end = _w(s, end + 1).end()
203 nextchar = s[end]
206 end += 1
211 raise ValueError(errmsg("Expecting ',' delimiter", s, end - 1))
214 nextchar = s[end]
216 end += 1
217 nextchar = s[end]
219 end = _w(s, end + 1).end()
220 nextchar = s[end]
224 end += 1
227 "Expecting property name enclosed in double quotes", s, end - 1))
230 return result, end
234 return pairs, end
237 s, end = s_and_end
239 nextchar = s[end:end + 1]
241 end = _w(s, end + 1).end()
242 nextchar = s[end:end + 1]
243 # Look-ahead for trivial empty array
245 return values, end + 1
249 value, end = scan_once(s, end)
251 raise ValueError(errmsg("Expecting object", s, end))
253 nextchar = s[end:end + 1]
255 end = _w(s, end + 1).end()
256 nextchar = s[end:end + 1]
257 end += 1
261 raise ValueError(errmsg("Expecting ',' delimiter", s, end))
263 if s[end] in _ws:
264 end += 1
265 if s[end] in _ws:
266 end = _w(s, end + 1).end()
270 return values, end
277 +---------------+-------------------+
281 +---------------+-------------------+
283 +---------------+-------------------+
285 +---------------+-------------------+
287 +---------------+-------------------+
289 +---------------+-------------------+
291 +---------------+-------------------+
293 +---------------+-------------------+
295 +---------------+-------------------+
297 It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
305 """``encoding`` determines the encoding used to interpret any ``str``
306 objects decoded by this instance (utf-8 by default). It has no
314 place of the given ``dict``. This can be used to provide custom
315 deserializations (e.g. to support JSON-RPC class hinting).
320 This feature can be used to implement custom decoders that rely on the
327 of every JSON float to be decoded. By default this is equivalent to
328 float(num_str). This can be used to use another datatype or parser
332 of every JSON int to be decoded. By default this is equivalent to
333 int(num_str). This can be used to use another datatype or parser
337 following strings: -Infinity, Infinity, NaN.
338 This can be used to raise an exception if invalid JSON numbers
343 this context are those with character codes in the 0-31 range,
364 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
365 end = _w(s, end).end()
366 if end != len(s):
367 raise ValueError(errmsg("Extra data", s, end, len(s)))
372 beginning with a JSON document) and return a 2-tuple of the Python
375 This can be used to decode a JSON document from a string that may
376 have extraneous data at the end.
380 obj, end = self.scan_once(s, idx)
383 return obj, end