Looking to dynamically choose a JSON key directly from the JSON Object.
var text =
'{"employees":[' + '{"firstName":"lastName", "lastName":"Doe" }]}';
var obj = JSON.parse(text);
var firstName = obj.employees[0].firstName;
var lName = obj.employees[0].firstName;
document.getElementById("demo").innerHTML =
firstName + " " + obj.employees[0].lName;
<div id="demo"></div>
Result Received: "lastName undefined".
Expected Result: "lastName Doe"