from airasia.OrderRelationEntity import OrderRelationEntity,PassengerEntity; import json from airasia.OrderRelation import OrderRelation; passengerEntity = PassengerEntity(); passengerEntity.bigNo = "7800214292" passengerEntity.birthday = "1965-07-18"; passengerEntity.firstName="WENTING"; passengerEntity.lastName = "ZHANG"; orderRelationEntity = OrderRelationEntity(); orderRelationEntity.passengers =passengerEntity; orderRelationEntity.orderNo = "c"; orderRelationEntity.singleAccount= "CNTRIPTOPK_ADMIN"; orderRelationEntity.singleAccountPassWord = "Tripto123"; # #将对象转换为字典 # orderRelationEntityDict = orderRelationEntity.__dict__; # print(orderRelationEntityDict); # #将字段转换为json orderRelationEntityJson = json.dumps(orderRelationEntity,default=lambda o: o.__dict__, sort_keys=True, indent=4); print(orderRelationEntityJson) # orderRelation = OrderRelation(orderRelationEntityJson); # orderRelation.worker(); # orderRelationEntityDict = json.loads(orderRelationEntityJson); # print(orderRelationEntityDict) # # # orderRelationEntity2 = OrderRelationEntity(); # orderRelationEntity2.__dict__ = orderRelationEntityDict; # print(orderRelationEntity2.passengers)