Iam a new gay about programmer, I use this code:
with codecs.open('test.json', 'a', 'utf-8') as jsonfile:
jsonfile.write(json.dumps(line, sort_keys = True, indent = 4) + '\n')
storage data in the jsonfile like this:
But When I want load() or loads() the data back in ram with follow "code 1" :
with codecs.open('test.json', 'r', 'utf-8') as file:
data = json.load(file)
print data
It raise: "ValueError: Extra data: line 20 column 1"
So, I change the "code 2":
with codecs.open('test.json', 'r', 'utf-8') as file:
for line in file.readlines():
data = json.loads(line)
print data
It raise: "ValueError: Expecting object: line 1 column 1 (char 0)"
But if I just sotrage "Json object one" in the jsonfile and used the "code 1", it work well. So can any help how to decode multiple json object in one json file? Thank you very much.