예제 #1
0
 def jsonDumps(data, objName="", schema=None):
     """
     Serialize data with JSON, optionally checking the schema
     @param data:
     @param objName:
     @param schema:
     @return:
     """
     if schema == None:
         msg = "No schema given for JSON serialization of "+objName
         Utils.log(msg, err=True)
         raise Exception(msg)  # Make sure we fail the request
     else:
         Schema.validate(schema, data, objName=objName)
     return json.dumps(data)
예제 #2
0
파일: server.py 프로젝트: hitocook/warmup2
 def jsonDumps(data, objName="", schema=None):
     """
     Serialize data with JSON, optionally checking the schema
     @param data:
     @param objName:
     @param schema:
     @return:
     """
     if schema == None:
         msg = "No schema given for JSON serialization of " + objName
         Utils.log(msg, err=True)
         raise Exception(msg)  # Make sure we fail the request
     else:
         Schema.validate(schema, data, objName=objName)
     return json.dumps(data)
예제 #3
0
    def jsonLoads(dataStr, objName="", schema=None):
        """
        Deserialize data with JSON, optionally checking the schema
        @param dataStr:
        @param objName:
        @param schema:
        @return:
        """
        data = json.loads(dataStr)

        if schema == None:
            msg = 'No schema given for JSON deserialization of '+objName
            Utils.log(msg, err=True)
            raise Exception(msg) # Make sure we fail the request
        else:
            Schema.validate(schema, data, objName=objName)
        return data
예제 #4
0
파일: server.py 프로젝트: hitocook/warmup2
    def jsonLoads(dataStr, objName="", schema=None):
        """
        Deserialize data with JSON, optionally checking the schema
        @param dataStr:
        @param objName:
        @param schema:
        @return:
        """
        data = json.loads(dataStr)

        if schema == None:
            msg = 'No schema given for JSON deserialization of ' + objName
            Utils.log(msg, err=True)
            raise Exception(msg)  # Make sure we fail the request
        else:
            Schema.validate(schema, data, objName=objName)
        return data