This is my JSON variable.
var json = { input: "hello", payload: { pay1: 123, pay2: 456 } };
Now, I have a variable keypay1
var keypay1 = "payload.pay1";
Question 1: How can I get the value of json.payload.pay1 using just the dynamic variables json and keypay1??? I tried this and it gives me undefined.
console.log( json[keypay1] );
Similarly, Question 2: How can I set the value of json.payload.pay1 using just the dynamic variables json and keypay1???