@@ -249,9 +249,48 @@ def _to_untrimmed_dict(self, in_cls = None) -> dict:
249
249
250
250
return untrimmed
251
251
252
+ @staticmethod
253
+ def trim_dict (untrimmed : dict ,
254
+ to_json : bool = False ,
255
+ context : str = None ,
256
+ for_export : bool = False ) -> dict :
257
+ """Remove keys from ``untrimmed`` whose values are :obj:`None <python:None>` and
258
+ convert values that have ``.to_dict()`` methods.
259
+
260
+ :param untrimmed: The :class:`dict <python:dict>` whose values may still be
261
+ :obj:`None <python:None>` or Python objects.
262
+ :type untrimmed: :class:`dict <python:dict>`
263
+
264
+ :param to_json: If ``True``, will remove all keys from ``untrimmed`` that are not
265
+ serializable to JSON. Defaults to ``False``.
266
+ :type to_json: :class:`bool <python:bool>`
267
+
268
+ :param context: If provided, will inform the method of the context in which it is
269
+ being run which may inform special handling cases (e.g. where empty strings may
270
+ be important / allowable). Defaults to :obj:`None <python:None>`.
271
+ :type context: :class:`str <python:str>` or :obj:`None <python:None>`
272
+
273
+ :param for_export: If ``True``, indicates that the method is being run to
274
+ produce a JSON for consumption by the export server. Defaults to ``False``.
275
+ :type for_export: :class:`bool <python:bool>`
276
+
277
+ :returns: Trimmed :class:`dict <python:dict>`
278
+ :rtype: :class:`dict <python:dict>`
279
+ """
280
+ if not for_export :
281
+ return HighchartsMeta .trim_dict (untrimmed = untrimmed ,
282
+ to_json = to_json ,
283
+ context = context ,
284
+ for_export = for_export )
285
+
286
+ topology = untrimmed .get ('topology' , None )
287
+
288
+ return topology
289
+
252
290
def to_json (self ,
253
291
filename = None ,
254
- encoding = 'utf-8' ):
292
+ encoding = 'utf-8' ,
293
+ for_export : bool = False ):
255
294
"""Generate a JSON string/byte string representation of the object compatible with
256
295
the Highcharts JavaScript library.
257
296
@@ -271,6 +310,10 @@ def to_json(self,
271
310
to ``'utf-8'``.
272
311
:type encoding: :class:`str <python:str>`
273
312
313
+ :param for_export: If ``True``, indicates that the method is being run to
314
+ produce a JSON for consumption by the export server. Defaults to ``False``.
315
+ :type for_export: :class:`bool <python:bool>`
316
+
274
317
:returns: A JSON representation of the object compatible with the Highcharts
275
318
library.
276
319
:rtype: :class:`str <python:str>` or :class:`bytes <python:bytes>`
0 commit comments