【发布时间】:2022-01-12 11:08:21
【问题描述】:
我有一些 excel 文件。我想将它们转换为 JS 对象。我可以像下面这样转换为 Json。
{ "profileMenu.info": "Profile information",
"profileMenu.infos.generalInfo": "general information",
"profileMenu.infos.otherInfos": "Other information" }
我需要像这样转换它们。
profileMenu: {
info: 'Profile information',
infos: {
generalInfo: 'general information',
otherInfos: 'Other information',
}
我已经搜索了执行此操作的方法,但找不到任何方法。您能帮我了解如何将此 Json 转换为 JS 对象吗?
【问题讨论】:
-
{ profileMenu.info: "Информация о профиле",不是有效的 JSON。在 JSON 中,键必须用双引号括起来。除此之外,如果您有JSON编码字符串,您可以将其复制并粘贴到 JS 代码中并将其用作 JavaScript 对象。编码为 JSON 的数据是 JS 代码中 JavaScript 对象的有效表示。 -
嗯,JSON 中的 JSO 代表什么?
-
@t.niese 你说得对,我在 Json 键中有双引号。我编辑了。
标签: javascript python json javascript-objects