'Try to load the string with the json module. If successful it\'s a json file.'

def sniff(self, filename):

    if self._looks_like_json(filename):
        try:
            ipynb = json.load(open(filename))
            if ((ipynb.get('nbformat', False) is not False) and ipynb.get('metadata', False)):
                return True
            else:
                return False
        except:
            return False
