Please help: update a value in data record using appVars as both the key and the value

How can I update a value in data record using appVars as both the key and the value to update?

Here’s all the things I tried that didn’t work!

Assume
{"Key1": "Value1",
"Key2": "Value2",
"id": 1}
and
appVars.KeyToUpdate == Key1 and appVars.NewValue == Value3

Update a Record bound to a formula:
SET_KEY(SingleDataRecord, appVars.KeyToUpdate, appVars.NewValue).
I have no idea why this isn’t working. I think maybe it returns

{"Key1": "Value1",
"Key2": "Value2",
"id": 1,
"Key1": "Value3"}

and it only takes the first Key1

I also tried
{"id":1, appVars.KeyToUpdate:appVars.NewValue}

Since they are variable, it doesn’t work. I think because there are no quotes.
It says "invalid syntax, : unexpected

But
{"id":1, "appVars.KeyToUpdate":"appVars.NewValue"} returns the strings rather than the variable values of course.

You have a space between “Key 1”, and not one “Key1”, so they are 2 different keys.

Sorry, typo in my example. Good point though I made certain sure they were the same.
(edited it to correct)

I dont know why the SET_KEY above wouldnt work. Can you confirm exactly what it returns by displaying its value in an Alert dialog?