【发布时间】:2015-06-15 21:04:00
【问题描述】:
我有一个读入 Javascript 对象的 XML 文件。这称为 jsonXML。当我记录它时,我可以在控制台中看到它的全部内容。这是一个非常复杂的对象,有很多层和重复。
我需要访问其中一些重复的对象,但我似乎无法深入了解我需要的细节。我遇到的问题是重复的对象。
JS对象的结构如下:
-
个人资料组:
-
文件:(我需要访问 85 个“文件对象”)
- 0:(我认为在树中这是文件的数组索引)
-
简介:
- WayPt:(我需要访问两个文件都有两个“WayPt”对象)
- 0:(我认为在树中这是WayPt的数组索引)
- 距离
- 本地坐标
-
WayPt:
- 1:(我认为在树中这是WayPt的数组索引)
- 距离
- 本地坐标
- 1:(我认为在树中这是WayPt的数组索引)
-
简介:
- 0:(我认为在树中这是文件的数组索引)
-
文件:(我需要访问 85 个“文件对象”)
我只是用它来尝试访问对象:
console.log(jsonXML.ProfileGroup.File.Profile.WayPt);
我可以使用console.log(jsonXML.ProfileGroup.File); 获取文件数组
但我无法获得单独的“文件”对象或其他任何东西。
有关此问题的任何信息都会有所帮助。谢谢!
更新
这里有一些令人生厌的 JSON,希望看到它的人:
"xmlns": "www.geophysical.com/DZX/1.02",
"GlobalProperties": {
"verticalUnit": "cm",
"horizontalUnit": "m",
"dielectric": "1.8000000",
"readOnly": "0",
"unitsPerMark": "100.0000000",
"unitsPerScan": "0.0200000"
},
"Macro": {
"state": "0",
"Process": [
{
"state": "0",
"BinaryData": "0&``!```$$`!C``H``````\"`@\n"
},
{
"state": "0",
"BinaryData": "L+``!```$)`!-`C,ST[\\`````````````A$$````````````````````````@\n"
},
{
"state": "0",
"BinaryData": "ME@`!```$C@`[`P````!!``\"X00``A$(`````````````````````````````\nM````````````````````````````````@$H``,A\"``#_`P``````````````\nM````````````````````````````````````````````````````````````\n/````````````````````\n"
},
{
"state": "0",
"BinaryData": "M2``!```$0``$```````#```````````````````````@`V0```#_`P``````\n;````````````````````````````````````\n"
},
{
"state": "0",
"BinaryData": "0$``!```$\"``G`0```````\"`@\n"
}
]
},
"ProfileGroup": {
"scanRange": "0,88815",
"Radan3D": {
"localMinCoords": "-0.5000000,0.0000000,0.0000000",
"localMaxCoords": "18.0000000,25.0000000,0.0000000",
"globalMinCoords": "0.0000000,0.0000000,0.0000000",
"globalMaxCoords": "0.0000000,0.0000000,0.0000000",
"localRotationAngle": "0.0000000",
"displayXDirProfs": "1",
"displayYDirProfs": "1",
"displayOtherDirProfs": "0",
"hide": "0",
"localGain": "0.0000000",
"displayOrder": "0",
"flipDataInVertDir": "0",
"flipDataInHorizDir": "0"
},
"File": [
{
"scanRange": "0,887",
"name": "HARMONY __050.DZT",
"Profile": {
"scanRange": "0,887",
"Comment": {
"scan": "0",
"description": "Data Collection Notes: "
},
"WayPt": [
{
"scan": "0",
"mark": "User",
"name": "Mark2",
"distance": "0.0000000",
"localCoords": "0.0000000,0.5000000,0.0000000"
},
{
"scan": "887",
"distance": "18",
"localCoords": "18,0.5000000,0.0000000"
}
]
}
},
{
"scanRange": "888,1785",
"name": "HARMONY __051.DZT",
"Profile": {
"scanRange": "888,1785",
"Comment": {
"scan": "888",
"description": "Data Collection Notes: "
},
"WayPt": [
{
"scan": "888",
"mark": "User",
"name": "Mark2",
"distance": "0.0000000",
"localCoords": "18.0000000,0.5208333,0.0000000"
},
{
"scan": "1785",
"distance": "17.9400000",
"localCoords": "0.0600000,0.5208333,0.0000000"
}
]
}
},
{
"scanRange": "1786,2681",
"name": "HARMONY __052.DZT",
"Profile": {
"scanRange": "1786,2681",
"Comment": {
"scan": "1786",
"description": "Data Collection Notes: "
},
"WayPt": [
{
"scan": "1786",
"mark": "User",
"name": "Mark2",
"distance": "0.0000000",
"localCoords": "-0.5000000,1.0416667,0.0000000"
},
{
"scan": "2681",
"distance": "17.9000000",
"localCoords": "17.4000000,1.0416667,0.0000000"
}
]
}
},
{
"scanRange": "2682,3574",
"name": "HARMONY __053.DZT",
"Profile": {
"scanRange": "2682,3574",
"Comment": {
"scan": "2682",
"description": "Data Collection Notes: "
},
"WayPt": [
{
"scan": "2682",
"mark": "User",
"name": "Mark2",
"distance": "0.0000000",
"localCoords": "18.0000000,1.5625000,0.0000000"
},
{
"scan": "3574",
"distance": "17.8400000",
"localCoords": "0.1600000,1.5625000,0.0000000"
}
]
}
},
{
"scanRange": "3575,4470",
"name": "HARMONY __054.DZT",
"Profile": {
"scanRange": "3575,4470",
"Comment": {
"scan": "3575",
"description": "Data Collection Notes: "
},
"WayPt": [
{
"scan": "3575",
"mark": "User",
"name": "Mark2",
"distance": "0.0000000",
"localCoords": "-0.5000000,2.0833333,0.0000000"
},
{
"scan": "4470",
"distance": "17.9000000",
"localCoords": "17.4000000,2.0833333,0.0000000"
}
]
}
},
{
"scanRange": "4471,5370",
"name": "HARMONY __055.DZT",
"Profile": {
"scanRange": "4471,5370",
"Comment": {
"scan": "4471",
"description": "Data Collection Notes: "
},
"WayPt": [
{
"scan": "4471",
"mark": "User",
"name": "Mark2",
"distance": "0.0000000",
"localCoords": "18.0000000,2.6041667,0.0000000"
},
{
"scan": "5370",
"distance": "17.9800000",
"localCoords": "0.0200000,2.6041667,0.0000000"
}
]
}
}
]
}
}
文件很长,所以我在文件末尾截断了它。
【问题讨论】:
-
您能否向我们展示实际的 JSON 而不是“结构”列表?
标签: javascript arrays xml object