</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/4935632/parse-json-in-javascript" dir="ltr">Parse JSON in JavaScript? [duplicate]</a>
<span class="question-originals-answer-count">
(16 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2013-06-15 12:02:59Z" class="relativetime">6 years ago</span>.</div>
</div>
</aside>
I have an ajax routine that return a string that looks something like this
[["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"]]
What is the easiest and fastest way of converting that string into an array of arrays, the syntax is practically the same as if you were to define the same structure in javascript, is there a way to execute it as javascript and get an array variable out of it?
</div>
This is called JSON.
You're looking for JSON.parse
.
Use JSON.parse
and parse the response text. This will give you your array of arrays.
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);