JQuery Parsing JSON array

后端 未结 5 1288
情话喂你
情话喂你 2020-12-02 11:46

I have a JSON output like the following:

[\"City1\",\"City2\",\"City3\"]

I want to get each of the city names, how can i do th

5条回答
  •  半阙折子戏
    2020-12-02 12:04

    Use the parseJSON method:

    var json = '["City1","City2","City3"]';
    var arr = $.parseJSON(json);
    

    Then you have an array with the city names.

提交回复
热议问题