jQuery addClass example

Change class name on click in jQuery

HTML

<pre><div id="json_before"></div></pre>
<br />
<pre><div id="json_after"></div></pre>

JavaScript

function modifySlotKey(requestObjectIntent, slotValue) {

requestObjectIntent['slots'][slotValue] = requestObjectIntent['slots']['toChange'];
delete(requestObjectIntent['slots']['toChange']);

return requestObjectIntent;
}

let variable = {"slots": {
  "toChange": {
    "name": "query",
    "value": "torte",
    "confirmationStatus": "NONE",
    "source": "USER"
  }
}};

modifySlotKey(variable,'slotValue');

$("#json_after").html(JSON.stringify(variable,undefined,2));