Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

Release 1.9.1
=========================================

* **ENHANCEMENT:** Added stringified JSON serialization of callback functions when serializing via
``.to_json(for_export = True)``.

----

Release 1.9.0
=========================================

Expand Down
2 changes: 1 addition & 1 deletion highcharts_core/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.9.0'
__version__ = '1.9.1'
7 changes: 6 additions & 1 deletion highcharts_core/metaclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,12 @@ def trim_dict(untrimmed: dict,
as_dict[key] = value
# Callback Function
elif checkers.is_type(value, 'CallbackFunction') and to_json:
continue
if not for_export:
continue
elif value:
trimmed_value = str(value)
if trimmed_value and trimmed_value != 'None':
as_dict[key] = trimmed_value
# HighchartsMeta -> dict --> object
elif value and hasattr(value, '_to_untrimmed_dict'):
untrimmed_value = value._to_untrimmed_dict()
Expand Down
3 changes: 3 additions & 0 deletions highcharts_core/utility_classes/javascript_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def _to_untrimmed_dict(self, in_cls = None) -> dict:
}

def to_json(self, encoding = 'utf-8', for_export: bool = False):
if for_export:
return str(self)

return None

def to_js_literal(self,
Expand Down