def _make_trigger_for_json(insert_or_update, table, column):
    'Return a SQL statement for creating a temporary trigger. The\n    trigger is used to validate the contents of TEXT_JSON type columns.\n    The trigger will pass without error if the JSON is wellformed.\n    '
    if (insert_or_update.upper() not in {'INSERT', 'UPDATE'}):
        msg = f"expected 'INSERT' or 'UPDATE', got {insert_or_update!r}"
        raise ValueError(msg)
    if SQLITE_JSON1_ENABLED:
        when_clause = f'''
            NEW.{column} IS NOT NULL
            AND json_valid(NEW.{column}) = 0
        '''.rstrip()
    else:
        when_clause = f'''
            NEW.{column} IS NOT NULL
            AND is_wellformed_json(NEW.{column}) = 0
        '''.rstrip()
    return f'''
        CREATE TEMPORARY TRIGGER IF NOT EXISTS trigger_check_{insert_or_update.lower()}_{table}_{column}
        BEFORE {insert_or_update.upper()} ON main.{table} FOR EACH ROW
        WHEN{when_clause}
        BEGIN
            SELECT RAISE(ABORT, '{table}.{column} must be wellformed JSON');
        END;
    '''
Return a SQL statement for creating a temporary trigger. The
trigger is used to validate the contents of TEXT_JSON type columns.
The trigger will pass without error if the JSON is wellformed.
def _make_trigger_for_json(insert_or_update, table, column):
    'Return a SQL statement for creating a temporary trigger. The\n    trigger is used to validate the contents of TEXT_JSON type columns.\n    The trigger will pass without error if the JSON is wellformed.\n    '
    if (insert_or_update.upper() not in {'INSERT', 'UPDATE'}):
        msg = f"expected 'INSERT' or 'UPDATE', got {insert_or_update!r}"
        raise ValueError(msg)
    if SQLITE_JSON1_ENABLED:
        when_clause = f'
            NEW.{column} IS NOT NULL
            AND json_valid(NEW.{column}) = 0
        '.rstrip()
    else:
        when_clause = f'
            NEW.{column} IS NOT NULL
            AND is_wellformed_json(NEW.{column}) = 0
        '.rstrip()
    return f'
        CREATE TEMPORARY TRIGGER IF NOT EXISTS trigger_check_{insert_or_update.lower()}_{table}_{column}
        BEFORE {insert_or_update.upper()} ON main.{table} FOR EACH ROW
        WHEN{when_clause}
        BEGIN
            SELECT RAISE(ABORT, '{table}.{column} must be wellformed JSON');
        END;
    '