Occ config:system:set an associative array as value?

I’m attempting to configure a Redis cache as it is described here. But I’d like to use the occ command, if possible, instead of editing the config file. The value I need to set is an associative array, e.g. as given on that page:

'redis' => array(
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'password' => 'secret',
    'timeout' => 1.5,

How can I do this? The documentation of config:system:set here does not explain how to use an associative array (only a plain array) and occ config:import refuses my attempt to go through JSON, too.

How do I do this correctly? Can it be done?

you can import the config as a json file with occ config:import

Hey @Reiner_Nippes, thank you! This seems to be a bit of an all-or-nothing thing. I’m trying to be more fine-grained, which is why I’m trying to use occ instead of writing the config file directly, for example.

FWIW, a little PHP script seems to do the job:

require_once 'lib/base.php';
$config = \OC::$server->getConfig()->getSystemConfig();
$config->setValues( [
    'redis' => [
        'host' => '/var/run/redis/redis.sock',
        'port' => 0,
        'dbindex' => 0,
        'password' => 'secret',
        'timeout' => 1.5
]] );

It needs to be executed in the root directory of the installation (and preferably not be saved there).

In my ansible playbook I use one json file to set “all” parameters. But as far as I remember you can set each parameter individual.

So this json would do the job:

"system": {
    "redis": {
        "host": "\/var\/run\/redis\/redis.sock",
        "port": "0",
        "dbindex": "0",
        "password": "secret",
        "timeout": "1.5"
    "memcache.locking": "\\OC\\Memcache\\Redis",
    "filelocking.enabled": "true"