Takes the parsed JSON (output from json.load) from a configuration file 
        and checks it for common errors.

def validate_config_json(pjson):
        """Takes the parsed JSON (output from json.load) from a configuration file 
        and checks it for common errors."""
        # Make sure that the root json is a dict
        if type(pjson) is not dict:
            raise ParseError("Configuration file should contain a single JSON object/dictionary. Instead got a %s." 
                             % type(pjson))

        # if 'configuration' is present it should be a dict of strings and numbers.
        # The ArgumentParser will do the rest of the validation.
        configuration = pjson.get('configuration', {})
        if type(configuration) is not dict:
            raise ParseError('''"configuration" object should be a dict, got %s instead.''' 
                             % type(configuration))

        # Make sure that the 'tests' key is present 
        try:
            tests = pjson["tests"]
        except KeyError:
            raise KeyError("Configuration file requires 'tests' attribute.")

        # Verify that 'options' is a dict if present
        options = pjson.get('options', {})
        if type(options) is not dict:
            raise ParseError('"options" attribute must be a dictionary"')

        # We need to know whether --user-defined-threads option is present to do 
        # the rest of the validation.
        if '-u' in options.keys() or '--user-defined-threads' in options.keys():
            ConfigurationValidator.validate_user_threaded_json(pjson)
        else:
            ConfigurationValidator.validate_auto_threaded_json(pjson)