Skip to content

Commit ad469cc

Browse files
committed
use mark_safe for json output
1 parent 54e4b16 commit ad469cc

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pyflot/graph.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import inspect
1616
import json
1717
import time
18+
from django.utils.safestring import mark_safe
1819

1920

2021
__title__ = 'pyflot'
@@ -23,6 +24,9 @@
2324
__license__ = 'MIT'
2425
__copyright__ = 'Copyright 2011 Brian Luft'
2526

27+
def safe_json(obj):
28+
return mark_safe(json.dumps(obj))
29+
2630

2731
def update(d, u):
2832
"""
@@ -84,7 +88,7 @@ def series_json(self):
8488
associated with this graph formatted as JSON,
8589
suitable for passing to the ``$.plot`` method.
8690
"""
87-
return json.dumps([self.prepare_series(s) for s in self._series])
91+
return safe_json([self.prepare_series(s) for s in self._series])
8892

8993
@property
9094
def options_json(self):
@@ -93,7 +97,7 @@ def options_json(self):
9397
for this graph in a format suitable for passing to
9498
the ``$.plot`` method as the options parameter.
9599
"""
96-
return json.dumps(self._options)
100+
return safe_json(self._options)
97101

98102
def __getattr__(self, value):
99103
"""

0 commit comments

Comments
 (0)