mirror of https://github.com/docker/docker-py.git
1059-Fixing a bug with multiple json objects
This splits the text by CRLF and then json.loads each part independently instead of attempting the parse the whole string. Signed-off-by: Tristan Escalada <tristan@escalada.us>
This commit is contained in:
parent
8a6b1843c3
commit
f8b843b127
|
|
@ -251,8 +251,16 @@ class Client(
|
|||
if decode:
|
||||
if six.PY3:
|
||||
data = data.decode('utf-8')
|
||||
data = json.loads(data)
|
||||
yield data
|
||||
# remove the trailing newline
|
||||
data = data.strip()
|
||||
# split the data at any newlines
|
||||
data_list = data.split("\r\n")
|
||||
# load and yield each line seperately
|
||||
for data in data_list:
|
||||
data = json.loads(data)
|
||||
yield data
|
||||
else:
|
||||
yield data
|
||||
else:
|
||||
# Response isn't chunked, meaning we probably
|
||||
# encountered an error immediately
|
||||
|
|
|
|||
Loading…
Reference in New Issue