MCPcopy Create free account
hub / github.com/docker/docker-py / json_splitter

Function json_splitter

docker/utils/json_stream.py:22–32  ·  view source on GitHub ↗

Attempt to parse a json object from a buffer. If there is at least one object, return it and the rest of the buffer, otherwise return None.

(buffer)

Source from the content-addressed store, hash-verified

20
21
22def json_splitter(buffer):
23 """Attempt to parse a json object from a buffer. If there is at least one
24 object, return it and the rest of the buffer, otherwise return None.
25 """
26 buffer = buffer.strip()
27 try:
28 obj, index = json_decoder.raw_decode(buffer)
29 rest = buffer[json.decoder.WHITESPACE.match(buffer, index).end():]
30 return obj, rest
31 except ValueError:
32 return None
33
34
35def json_stream(stream):

Calls 1

matchMethod · 0.80