diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py
index f9385a2c83..31094df4a1 100644
--- a/synapse/storage/databases/main/devices.py
+++ b/synapse/storage/databases/main/devices.py
@@ -15,6 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
+from canonicaljson import json
from typing import Dict, Iterable, List, Optional, Set, Tuple
from synapse.api.errors import Codes, StoreError
@@ -815,7 +816,7 @@ class DeviceWorkerStore(SQLBaseStore):
self._store_dehydrated_device_txn,
user_id,
device_id,
- json.dumps(device_data),
+ json_encoder.encode(device_data),
)
async def create_dehydration_token(
@@ -845,7 +846,7 @@ class DeviceWorkerStore(SQLBaseStore):
"token": token,
"user_id": user_id,
"device_id": device_id,
- "login_submission": json.dumps(login_submission),
+ "login_submission": json_encoder.encode(login_submission),
"creation_time": self.hs.get_clock().time_msec(),
},
desc="create_dehydration_token",
diff --git a/synapse/storage/databases/main/end_to_end_keys.py b/synapse/storage/databases/main/end_to_end_keys.py
index a1291b06ff..3d105eb65c 100644
--- a/synapse/storage/databases/main/end_to_end_keys.py
+++ b/synapse/storage/databases/main/end_to_end_keys.py
@@ -288,7 +288,7 @@ class EndToEndKeyWorkerStore(SQLBaseStore):
},
values={
"key_id": key_id,
- "key_json": json.dumps(fallback_key),
+ "key_json": json_encoder.encode(fallback_key),
"used": 0
},
desc="set_e2e_fallback_key"
|