javascript - 从 json 读取嵌套值

标签 javascript arrays json vue.js nativescript

在图片上你可以看到我想读的内容

console.log("exact val = " + json._array.loftybot.spells.name)

它给出 [TypeError: Cannot read property 'spells' of undefined] 你可以在json的终端结构中看到

如何获取这些值? 我想将值从 json 保存到数组 const json = new ObservableArray 然后在我的程序中使用所有这些值

enter image description here

最佳答案

json._array[0].loftybot.spells.name怎么样?在 _array 上使用索引 0 并进一步处理嵌套 json。请参阅 MDN

关于javascript - 从 json 读取嵌套值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55083596/

相关文章:

javascript - 当我重定向到某个页面时,根据国家/地区的不同,该页面在 https 中不起作用

javascript - 如何将 css 属性添加到 Canvas

javascript - 添加文本框和按钮

java - 在 Java 中使用 Jackson 从 ObjectNode 创建字符串的速度很慢

android - retrofit 2.0如何忽略json对象动态响应的key

javascript - 如何在 AJAX foreach JSON 返回调用中引入延迟和淡入

php - WooCommerce:向 WC Vendors Pro 添加额外的表单字段属性

php - 使用数组值作为查询中的 where 子句并递增查询的编号 php

json - 如何使用剑道网格进行服务器分组?预期的 json 格式是什么?

复制一个 3 dim 数组本身