Detect when any plugin is activated or deactivated

There are few solutions. You can use activate_plugin and deactivate_plugin hooks for example.

But… As far as I understand you right, you want to get notified whenever list of plugins get changed and not when a plugin is activated or deactivated.

So the easiest way will be hooking onto update_option.

add_action('updated_option', function( $option_name, $old_value, $value ) {
    if ( 'active_plugins' == $option_name ) {
        // update your json file based on $value
    }
}, 10, 3);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)