var type = "value1"; var custom = { key: { label: "test" } }; custom[type] = custom.key; delete custom.key; alert(JSON.stringify(custom,0,'\t'));