Javascript 无法访问JSON对象(stringified)中的字段,我使用的是Quasar/vue.js

Javascript 无法访问JSON对象(stringified)中的字段,我使用的是Quasar/vue.js,javascript,arrays,json,vue.js,xml2js,Javascript,Arrays,Json,Vue.js,Xml2js,我使用xml2js parseString()将excel电子表格转换为JSON对象,然后对结果使用JSON.stringify 我已经在控制台中查看了该数据,并且可以看到数据的形式,看起来我应该能够轻松地遍历它以显示感兴趣的字段 然而,我尝试了多种形式的v-for来遍历文件“Cell”和“Cell” 我们非常赞赏任何解决方案的方向 这是我的密码 <template> <q-page class="flex flex-center"> &l

我使用xml2js parseString()将excel电子表格转换为JSON对象,然后对结果使用JSON.stringify

我已经在控制台中查看了该数据,并且可以看到数据的形式,看起来我应该能够轻松地遍历它以显示感兴趣的字段

然而,我尝试了多种形式的v-for来遍历文件“Cell”和“Cell”

我们非常赞赏任何解决方案的方向

这是我的密码

<template>
  <q-page class="flex flex-center">
    <div>
      <div v-for="(jsonObject, i) in json" :key="i">
        {{ jsonObject }}
      </div>
    </div>
  </q-page>
</template>

<script>
import { parseString } from 'xml2js'
// import xml2js from 'xml2js'
export default {
  name: 'PageIndex',
  data() {
   return {
     xmlObj: [],
     jsonObj: [],
     json: []
   }
  },
  methods: {
    convertXmltoJs() {
      this.$axios(`saundz_curriculum.xml`).then(response => {
        // console.log('response.data:', response.data)
        parseString(response.data, (err, result) => {
          if(err) {
            console.log('err:', err)
          } else {
            this.jsonObj = result
            // JSON object with XML data
            // console.log('jsonObj:', this.jsonObj)
            // stringify JSON object
            this.json = JSON.stringify(result, null, 4);
            // log JSON object stringified
            console.log('json:', this.json)
          }
        })
      })
    }
  }
}
</script>

如果我查看JSON.stringify之前的对象,下面是我在控制台日志中看到的内容

When I console.log the result before stringify I can see the data I want but I am not sure how to access it. 

jsonObj: 
-- (obj: Observer) 
......Table: Object 
........Row: Array (5) 
..........0: 
............Cell: (...) 
.............__ob__: Observer 
...............dep: Dep {id: 2260, subs: Array(0)} 
................value: 
..................Cell: Array(11) 
.....................0: 
.......................Data: Array(1) 
.........................0: "CHAPTER" 

And that is what I want to get at, the "CHAPTER".

谢谢你,德克塞,你让我看到了正确的方向

我确实对xml2js对象进行了字符串化,也许我添加了一个额外的步骤,但下面是我的代码,它为我提供了“章节”等等


跳过
JSON.stringify
…!?这使它成为一个字符串,不能像对象那样访问它。
When I console.log the result before stringify I can see the data I want but I am not sure how to access it. 

jsonObj: 
-- (obj: Observer) 
......Table: Object 
........Row: Array (5) 
..........0: 
............Cell: (...) 
.............__ob__: Observer 
...............dep: Dep {id: 2260, subs: Array(0)} 
................value: 
..................Cell: Array(11) 
.....................0: 
.......................Data: Array(1) 
.........................0: "CHAPTER" 

And that is what I want to get at, the "CHAPTER".
    convertXmltoJSON() {
      this.$axios(`saundz_curriculum.xml`).then(response => {
        parseString(response.data, (err, result) => {
          if(err) {
            console.log('err:', err)
          } else {
            this.stringifyJSON(result)
          }
        })
      })
    },
    stringifyJSON(result) {
      const jsonParse = JSON.parse(JSON.stringify(result))
      console.log('jsonParse.row:', jsonParse.Table.Row[0].Cell[0].Data)
    }