无法将json对象转换为2D数组

par*_*tho 2 javascript arrays jquery json

我有一个JSON对象:

var info=JSON.parse(server_response);
Run Code Online (Sandbox Code Playgroud)

我跑了console.log(info); 并得到了这个输出:

[  
  [  
    [  
      "Dipu",
      "Mondal",
      "O Positive",
      "017xxxx",
      "AIS"
    ]
  ],
  [  
    [  
      "dipu",
      "Roy",
      "O Positive",
      "017xxxx",
      "Electrical"
    ]
  ],
  [  
    [  
      "Dhinka",
      "Chika",
      "O Positive",
      "9038485777",
      "stat"
    ]
  ]
]
Run Code Online (Sandbox Code Playgroud)

跟着这个小提琴:http://jsfiddle.net/6CGh8/我试过:

console.log(info.length); //output: 161
console.log(info[0].length); //output: 1
console.log(info[0][1]); //output: undefined
Run Code Online (Sandbox Code Playgroud)

而这3条线的预期输出(分别):

3
5
Dipu

为什么我期待这个:

这个JSON对象包含3个数组,每个数组有5个数据,[0][1]第th个元素是Dipu.

如何获得预期的输出?

Faq*_*arl 5

你有json编码两次,所以info只是一个文本而不是一个数组.

info.length    // length of the string
info[0].length // length of a character (1)
info[0][1]     // undefined because a character is not an array
Run Code Online (Sandbox Code Playgroud)

尝试 var info = JSON.parse(JSON.parse(server_response))