Skip to content

Switch_os: keep dictionary entries when switch_os returns dict

Tobias Gröger requested to merge feature/switch_os-keep-dict-entries into main

Currently switch_os replaces the whole json object with the switched value and thus discards any additional entries. Change the behavior so that when the switched value is a dictionary itself, it's values are added to the json object instead.

I don't know if this will break any existing configurations but this is an idea of how to fix #201 (closed).

Example:

{
  "a": "A",
  "axii.switch_os": {
    "bionic": {
      "entry_bionic": "value_bionic",
      "another_entry": "another_value"
    },
    "default": {
      "entry_default": "value_default"
    }
  },
  "c": "C"
}

On the platform bionic, the above JSON example would be interpreted as:

{
  "a": "A",
  "entry_bionic": "value_bionic",
  "another_entry": "another_value",
  "c": "C"
}

When the value of the switch_os is not a dictionary, keep the old behavior.

Example:

{
  "a": "A",
  "axii.switch_os": {
    "bionic": "value_bionic",
    "default": "value_default"
  },
  "c": "C"
}

On the platform bionic, the above JSON example would be interpreted as:

"value_bionic"
Edited by Tobias Gröger

Merge request reports