comparison sat/tools/common/data_format.py @ 2709:46f2733a2a9b

tools (common/data_format): use "default" in json.dumps in serialise (useful notably to serialise jid.JID)
author Goffi <goffi@goffi.org>
date Sat, 01 Dec 2018 14:34:55 +0100
parents fcc945537d5f
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2708:0b5deb9a35fd 2709:46f2733a2a9b
129 def serialise(data): 129 def serialise(data):
130 """Serialise data so it can be sent to bridge 130 """Serialise data so it can be sent to bridge
131 131
132 @return(unicode): serialised data, can be transmitted as string to the bridge 132 @return(unicode): serialised data, can be transmitted as string to the bridge
133 """ 133 """
134 return json.dumps(data, ensure_ascii=False) 134 return json.dumps(data, ensure_ascii=False, default=unicode)
135 135
136 def deserialise(serialised_data, default=None, type_check=dict): 136 def deserialise(serialised_data, default=None, type_check=dict):
137 """Deserialize data from bridge 137 """Deserialize data from bridge
138 138
139 @param serialised_data(unicode): data to deserialise 139 @param serialised_data(unicode): data to deserialise