Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Dicctionary serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodbare committed Nov 28, 2016
1 parent 41864c8 commit d1ae898
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/plone.server/plone/server/json/serialize_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from zope.interface import implementer
from zope.interface import Interface
from plone.server.text import IRichTextValue
from zope.schema.vocabulary import SimpleVocabulary

try:
import Missing
Expand Down Expand Up @@ -60,6 +61,12 @@ def default_converter(value):
' {0!r} ({1}) JSON compatible.'.format(value, type(value)))


@adapter(SimpleVocabulary)
@implementer(IValueToJson)
def vocabulary_converter(value):
return [x.token for x in value]


@adapter(str)
@implementer(IValueToJson)
def string_converter(value):
Expand Down
2 changes: 2 additions & 0 deletions src/plone.server/plone/server/json/serializers.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<adapter factory=".serialize_value.time_converter" />
<adapter factory=".serialize_value.timedelta_converter" />
<adapter factory=".serialize_value.tuple_converter" />
<adapter factory=".serialize_value.vocabulary_converter" />



</configure>

0 comments on commit d1ae898

Please sign in to comment.