When accessing the Body element through context.Request.Body or context.Response.Body by default the body is cleared from the object. In your case it seems that you are accessing this through a variable however I suspect this is still the issue you are experiencing.
To fix this simply add preserveContent: true to your .As<> method:
<set-variable name="name1" value="@((String)((IResponse)context.Variables["response-variable-name"]).Body.As<JObject>(preserveContent: true)["result"][0]["Key1"])" />
<set-variable name="name2" value="@((String)((IResponse)context.Variables["response-variable-name"]).Body.As<JObject>(preserveContent: true)["result"][0]["Key2"])" />
For more info please see the notes on this article: https://learn.microsoft.com/en-us/azure/api-management/set-body-policy