0

我有一个 ajax 例程,它返回一个看起来像这样的字符串

[["analog.__VG_SPP3_SFRTPCT","analog.__VG_SPP3_SFRTPCT"],
 ["analog._3305_LIST210_1","analog._3305_LIST210_1"],
 ["analog._AG_5340_PR14AN","analog._AG_5340_PR14AN"],
 ["analog._AG_EPNT_2","analog._AG_EPNT_2"],
 ["analog._AG_EPNT_SP","analog._AG_EPNT_SP"],
 ["analog._AG_MERC_ERXTES","analog._AG_MERC_ERXTES"],
 ["analog._AG_ROC_TEST","analog._AG_ROC_TEST"],
 ["analog._AG_ROM1_LOAD","analog._AG_ROM1_LOAD"],
 ["analog._AG_TEST_CRC1LT","analog._AG_TEST_CRC1LT"],
 ["analog._AG_TEST_CRC1RT","analog._AG_TEST_CRC1RT"],
 ["analog._CWAV_TST_MDP1CV","analog._CWAV_TST_MDP1CV"],
 ["analog._CWAV_TST_MDP1CV_LIST","analog._CWAV_TST_MDP1CV_LIST"],
 ["analog._CWAV_TST_MDP2CV","analog._CWAV_TST_MDP2CV"],
 ["analog._CWAV_TST_MDP2CV_LIST","analog._CWAV_TST_MDP2CV_LIST"],
 ["analog._CWAV_TST_MOR1CV","analog._CWAV_TST_MOR1CV"],
 ["analog._CWAV_TST_MOR1CV_LIST","analog._CWAV_TST_MOR1CV_LIST"],
 ["analog._CWAV_TST_MOR2CV_LIST","analog._CWAV_TST_MOR2CV_LIST"],
 ["analog._CWAV_TST_TIME001","analog._CWAV_TST_TIME001"],
 ["analog._CWAV_TST_TIME002","analog._CWAV_TST_TIME002"],
 ["analog._CWAV_TST_TIME003","analog._CWAV_TST_TIME003"]]

将该字符串转换为数组数组的最简单和最快的方法是什么,语法实际上与在 javascript 中定义相同的结构相同,有没有办法将其作为 javascript 执行并获取数组变量呢?

4

3 回答 3

3

这称为JSON

你正在寻找JSON.parse.

于 2013-06-14T17:41:49.240 回答
1

You would have to use JSON (Javascript Object Notation).

Something like:

var analogObject = JSON.parse(analogString);

You can turn it back to a string then with:

var analogString = JSON.stringify(analogObject);
于 2013-06-14T17:46:56.107 回答
0

使用JSON.parse和解析响应文本。这将为您提供数组数组。

于 2013-06-14T17:44:17.023 回答