I have a class in python. And I made a list that contains this class instances. I want to convert this list to json. Here is my class
class IpPort:
def __init__(self,ip,port,time,status):
self.ip=ip
self.port=port
self.time=time
self.status=status
And I have a list of this object. I want to convert this list to json format to send a socket. But I could not. How can I do this? I want it to be like:
{"IpPortList":{[]}}
EDIT Here is my code for this.But it did not work:
li=list()
i1=IpPort("kk",12,None,"w")
i2=IpPort("kk",15,None,"s")
li.append(i1)
li.append(i2)
jsons= json.dumps(li)
s.send(jsons)
And i want to send this json to a socket.After that i want to take the json at the other side.In the other side again i want to convert it to list.