How to create a key-value object from a text variable and add it to an associative array using only functions

Hi everyone,

I have an array of collections, for example:

I also have a text variable called: text.

How can I create a new key-value object like {"key": "key4", "value": text} and append it to my existing collection using only functions (no additional modules)?

Thanks in advance for your help!