[英]how to set object object inside the object in json?
can you please tell me how to set object inside the object having some key . 你能告诉我如何在有钥匙的物体内放置物体吗?
var item = {};
item[inputItem.text] : sessionStorage.getItem(inputItem.text);
I am getting error . 我出错了。 of : in my given line when I take this it take as string
of:在我给定的行中,当我接受它时,它作为字符串
item[inputItem.text] = sessionStorage.getItem(inputItem.text);
如果存储的项目是JSON(如您的注释所示),则JSON.parse()
会将其转换为JavaScript对象:
item[inputItem.text] = JSON.parse( sessionStorage.getItem(inputItem.text) );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.