X-Git-Url: https://git.mdrn.pl/django-ssify.git/blobdiff_plain/3d2c8ba4dfb4774daff367dae1656099eb2b562c..9c5fe2012a14bf1c840e304b1bd1d9f72fffba6a:/ssify/serializers.py?ds=sidebyside diff --git a/ssify/serializers.py b/ssify/serializers.py index a96356c..8a44c7b 100644 --- a/ssify/serializers.py +++ b/ssify/serializers.py @@ -1,19 +1,25 @@ +# -*- coding: utf-8 -*- +# This file is part of django-ssify, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See README.md for more information. +# +from __future__ import unicode_literals import json from .variables import SsiVariable, SsiExpect def _json_default(o): if isinstance(o, SsiVariable): - return {'__var__': o.name} + return {'__var__': o.definition} if isinstance(o, SsiExpect): return {'__expect__': o.name} raise TypeError(o, 'not JSON serializable') def _json_obj_hook(obj): - if obj.keys() == ['__var__']: - return SsiVariable(name=obj['__var__']) - if obj.keys() == ['__expect__']: + keys = list(obj.keys()) + if keys == ['__var__']: + return SsiVariable(*obj['__var__']) + if keys == ['__expect__']: return SsiExpect(obj['__expect__']) return obj