javascript - 如何警告 json 数组中的值?

标签 javascript json alert

我有一个 json 数组,我需要提醒其中的一个值。 该对象看起来像这样:

Test = [
         {
          "adj" : [
                    {
                      "nodeTo" : "x",
                      "nodeFrom" : y,
                      "data": 
                              {
                                "$type" : "line",
                                "$color" : "#A989BC",
                                "$value" : "number"
                              }
                     }
                   ],

          "id" : "id1",
          "name" : "name1"
         },
         {
          "adj" : [ ..... ]   // I have many element in the Test array

我想要的是提醒“adj”数组中存在的“data”数组中存在的值。 我试过这个:

alert(Test[0]["adj"]["data"]["value"]);

但是它不起作用。

提前致谢:)

最佳答案

adj 是一个数组:

alert(Test[0]["adj"][0]["data"]["value"]);

关于javascript - 如何警告 json 数组中的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12528708/

相关文章:

javascript - 显示和隐藏 div onclick 按钮

javascript - Bootstrap 模态在新页面上打开

javascript - yuidoc 解析但没有输出也没有错误

javascript - 提交表单后,从数据库中将订单号加载到警报框中

javascript - 添加到时间线与登录

javascript - 如何通过循环将解析推送到数组?

json - 无效的 json 响应正文错误,同时将 Next.js 应用程序部署到 Vercel

javascript - jQuery $.get 返回完整的对象与我需要的

ios - 通过快速警报更改屏幕

jquery - 使用 jquery 调用两个值时没有警报