def validateJSON():
        style=unicode(js.toPlainText())
        if not style.strip(): #no point in validating an empty string
            return
        pos=None
        try:
            json.loads(style)
        except __HOLE__, e:
            s=str(e)
            print s
            if s == 'No JSON object could be decoded':
                pos=0
            elif s.startswith('Expecting '):
                pos=int(s.split(' ')[-1][:-1])
            elif s.startswith('Extra data'):
                pos=int(s.split(' ')[-3])
            else:
                print 'UNKNOWN ERROR'
                
        # This makes a red bar appear in the line
        # containing position pos
        js.highlightError(pos)

    # Run validateJSON on every keypress
dataset/ETHPy150Open rst2pdf/rst2pdf/gui/codeeditor.py/validateJSON