How to append 1 item to an existing object map?

Hello guys.

I have a configuration defined by some map objects like this.

my_object_map = {
   "OBJECT1" = {  
         key1=value_ob11
         key2=value_ob12
     }
   "OBJECT2" = {
       key1=value_ob21
       key2=value_ob22
    }
  }

And I need add a new item to the map, something similar on how concat() does with list. ( a kind of “mapconcat” function)

my_new_map = mapconcat (my_object_map ,{"OBJECT3"= { key1=value_ob31, key2=value_ob32})

The result should be

my_new_map = {
   "OBJECT1" = {  
         key1=value_ob11
         key2=value_ob12
     }
   "OBJECT2" = {
       key1=value_ob21
       key2=value_ob22
    }
   "OBJECT3" = {
       key1=value_ob31
       key2=value_ob32
    }
  }

How can do this “mapconcat” ? there is any easy way to do it?

Hi @toni-moreno

The behavior of your mapconcat function is already implemented, and it’s called merge.

2 Likes