Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Use new canonicaljson serisalistion hook
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Mar 14, 2023
1 parent 266370c commit 03e63ab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion synapse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import json
import os
import sys
from typing import Any, Dict

from synapse.util.rust import check_rust_lib_up_to_date
from synapse.util.stringutils import strtobool
Expand Down Expand Up @@ -63,9 +64,15 @@

# Use the standard library json implementation instead of simplejson.
try:
from canonicaljson import set_json_library
from canonicaljson import register_preserialisation_callback, set_json_library
from immutabledict import immutabledict

set_json_library(json)

def _immutabledict_cb(d: immutabledict) -> Dict[str, Any]:
return d._dict

register_preserialisation_callback(immutabledict, _immutabledict_cb)
except ImportError:
pass

Expand Down

0 comments on commit 03e63ab

Please sign in to comment.