def add_json(self, data): """ Shortcut to add a json field to the ``Formdata``. Parameters ---------- data : `Any` Json serializable content. """ if data: type_options = multidict() type_options['name'] = 'data_json' data = dump_to_json(data, separators=(',', ':'), ensure_ascii=True) self.fields.append((type_options, multidict(), data))
def to_json(data): """ Converts the given object to json. Parameters ---------- data : `Any` Returns ------- json : `str` Raises ------ TypeError If the given object is /or contains an object with a non convertable type. """ return dump_to_json(data, separators=(',', ':'), ensure_ascii=True, default=added_json_serializer)
def add_json(self, data): if data: type_options = multidict() type_options['name'] = 'data_json' data = dump_to_json(data, separators=(',', ':'), ensure_ascii=True) self.fields.append((type_options, {}, data))
def test_get_policies_in_json_serializable_form(app, list_of_policies): json_serializable_form = get_policies_in_json_serializable_form( list_of_policies) assert all(dump_to_json(test) for test in json_serializable_form)
def to_json(data): return dump_to_json(data,separators=(',',':'),ensure_ascii=True)
def test_get_policies_in_json_serializable_form(app, list_of_policies): json_serializable_form = get_policies_in_json_serializable_form(list_of_policies) assert all(dump_to_json(test) for test in json_serializable_form)