'Ensure that JSON can be loaded by json.loads()'

@staticmethod
def pr_filter_onvalidation(form):

    query = form.vars.get('query', None)
    if query:
        query = query.replace("'", '"')
        try:
            json.loads(query)
        except ValueError as e:
            form.errors.query = ('%s:    %s' % (current.T('Query    invalid'), e))
        form.vars.query = query
