def to_json(things): """ If the model/object defines a "to_client" then call it first. This way objects can implement the "to_client" interface to return a dictionary representation of themselves to be serialized as json. """ return util.js_safety(util.client_dumps(things))
def daily_sticker_activity_json(user): activity = None if user.kv.has_unseen_daily_free_stickers.get(): user.kv.has_unseen_daily_free_stickers.delete() activity = DailyFreeStickersActivity({ 'reward_stickers': knobs.DAILY_FREE_STICKERS, }, actor=user) activity = activity_stream_item(activity, user) return util.js_safety(util.client_dumps(activity))
def to_escaped_json(things): return util.js_safety(util.client_dumps(things), django=False, escape_html=True)