首页 > 解决方案 > Nodejs创建具有多个值的字典错误

问题描述

我正在尝试为经过验证的地址创建字典。但我收到一个错误。我该如何解决?

语法错误:意外的标记“{”

const Addresses = {
    {
        "0x0000000000000000000000000000000000000000": "BURN", 
        "Verified": "Yes"
        "Type": "Address"
    },
    {
        "0x1010101010101010101010101010101010101010": "BURN", 
        "Verified": "No"
        "Type": "Address"
    }
}

标签: node.js

解决方案


您需要将变量类型从 json 更新为 object 并添加逗号。像这样。

const Addresses = [
    {
        "0x0000000000000000000000000000000000000000": "BURN", 
        "Verified": "Yes",
        "Type": "Address"
    },
    {
        "0x1010101010101010101010101010101010101010": "BURN", 
        "Verified": "No",
        "Type": "Address"
    }
]

{ ... } => [ ... ]

... : "Yes",

... : "No",


推荐阅读