类定义:
class people:
idno = "";
name = "";
def __init__(this,idno,name):
this.idno = idno;
this.name = name;
起数组,胡乱初始化下:
ps = [people("13000" + str(i) ,"tom" + str(i) ) for i in range(10)];
pd =[];#再整个空数组
for x in ps:#遍历数组内 对象
pd.append(x.__dict__);#对象转字典,附加到数组
import json
js = json.dumps(pd) #字典数组序列化成JSON串