JSON tag order in Python -
this question has answer here:
- how keep json key order fixed python 3 json.dumps? 2 answers
- json.dumps messes order 4 answers
i'm new python, been learning @ college , have question. first of all, important part of code in question:
#this on tcp client name = raw_input("box name: ") timestamp = time.time() json_dict = {'type': 'create', 'name': name, 'timestamp': timestamp} print json_dict tcp_s.send(pickle.dumps(json_dict)) #this on tcp server json_dict = pickle.loads(client_s.recv(65536)) file_received = json.dumps(json_dict,indent=4) print file_received
im trying carry on information client server , have convert json, successful. issue: order in presents type, name , timestamp tags arent want them be. think might due using dictionaries arent ordered , why im here.
the current output:
{ "timestamp": 1492173052.087644, "type": "create", "name": "test" }
any suggestion have output this?
{ "type": "create", "name": "test" "timestamp": 1492173052.087644, }
Comments
Post a Comment