@@ -859,7 +859,7 @@ def copy(self):
859859 return new
860860
861861
862- class JSONEncoder (json .JSONEncoder ):
862+ class _JSONEncoder (json .JSONEncoder ):
863863 def default (self , o ):
864864 if isinstance (o , FontManager ):
865865 return dict (o .__dict__ , __class__ = 'FontManager' )
@@ -877,6 +877,11 @@ def default(self, o):
877877 return super ().default (o )
878878
879879
880+ @cbook .deprecated ("3.2" , alternative = "json_dump" )
881+ class JSONEncoder (_JSONEncoder ):
882+ pass
883+
884+
880885def _json_decode (o ):
881886 cls = o .pop ('__class__' , None )
882887 if cls is None :
@@ -897,26 +902,32 @@ def _json_decode(o):
897902
898903def json_dump (data , filename ):
899904 """
900- Dumps a data structure as JSON in the named file.
905+ Dump `FontManager` *data* as JSON to the file named *filename*.
906+
907+ Notes
908+ -----
909+ File paths that are children of the Matplotlib data path (typically, fonts
910+ shipped with Matplotlib) are stored relative to that data path (to remain
911+ valid across virtualenvs).
901912
902- Handles FontManager and its fields. File paths that are children of the
903- Matplotlib data path (typically, fonts shipped with Matplotlib) are stored
904- relative to that data path (to remain valid across virtualenvs).
913+ See Also
914+ --------
915+ json_load
905916 """
906917 with open (filename , 'w' ) as fh :
907918 try :
908- json .dump (data , fh , cls = JSONEncoder , indent = 2 )
919+ json .dump (data , fh , cls = _JSONEncoder , indent = 2 )
909920 except OSError as e :
910921 _log .warning ('Could not save font_manager cache {}' .format (e ))
911922
912923
913924def json_load (filename ):
914925 """
915- Loads a data structure as JSON from the named file .
926+ Load a `FontManager` from the JSON file named *filename* .
916927
917- Handles FontManager and its fields. Relative file paths are interpreted
918- as being relative to the Matplotlib data path, and transformed into
919- absolute paths.
928+ See Also
929+ --------
930+ json_dump
920931 """
921932 with open (filename , 'r' ) as fh :
922933 return json .load (fh , object_hook = _json_decode )
0 commit comments