Exemple #1
0
def test_json():
    s = '[0, true, "False"]'
    compare(s, encode_json([0, True, 'False']))
    compare(s, encode_json(decode_json(s)))

    d = {'one': 0, 'two': True, 'three': 'False'}
    s = '{"three": "False", "two": true, "one": 0}'
    compare(s, encode_json(d))
    compare(d, decode_json(encode_json(d)))
Exemple #2
0
    def before(self):
        input = None

        if request.content_length:
            if request.mimetype == 'application/json':
                try:
                    input = self.filter.filter(decode_json(request.data))
                except:
                    raise InvalidJSONException(request.data)
            else:
                raise InvalidMimetypeException(request.mimetype)

        g.ctx.input = input
Exemple #3
0
 def json(self):
     return decode_json(self.data)
Exemple #4
0
 def _deserialize(self, data):
     return self.input_filter.filter(decode_json(data))
Exemple #5
0
 def process_result_value(self, value, dialect):
     if value is not None:
         value = self.model_class(**decode_json(value))
     return value