jsonplus似乎没有.dump(),只有一个.dumps()函数,所以您将如何使用jsonplus编写和读取例如namedtuple的列表?
具有以下作用:
import jsonplus as json
from collections import namedtuple
Person = namedtuple('Person', 'name age')
l = [Person('bob', '28'),
Person('joe', '29'),
Person('tom', '30')]
with open('test.json', 'w') as outfile:
json.dump(l, outfile, indent = 4)
with open('test.json', "r") as read_file:
read_data = json.load(read_file)
with open('test.json', 'w') as outfile:
outfile.write(json.dump(l))
with open('test.json', 'r') as read_file:
read_data = json.loads(read_file.read())