Example #1
0
    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))
Example #2
0
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)
Example #3
0
 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))
Example #4
0
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)
Example #5
0
def to_json(data):
    return dump_to_json(data,separators=(',',':'),ensure_ascii=True)
Example #6
0
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)