简体   繁体   中英

Turn a String to an array Declaration

In JS: I have this string ="[36.79025,3.01642],[36.71477,2.99761]"; I want it to be turned To a real Array =[[36.79025,3.01642],[36.71477,2.99761]]; Is this possible?

var string = "[36.79025,3.01642],[36.71477,2.99761]";
var arr = JSON.parse(`[${string}]`);
console.log(arr);
[[36.79025,3.01642],[36.71477,2.99761]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM