gpt4 book ai didi

javascript - 如何在 JavaScript 或 AngularJS 中从数组字符串获取数组?

转载 作者:行者123 更新时间:2023-12-03 06:23:37 25 4
gpt4 key购买 nike

最初我有包含字符串数据的变量

var stringArray = "[{'middleName':'T','lastName':'TEST5LAST','occupation':'QA','homeAddressZipcode':'85001','entitySequenceNumber':7,'homeAddressCity':'PHOENIX','ssn':'111111115','cellPhone':'4807363273','employer':'ABC','workPhoneExtension':'5555','entityType':'JOINT','homePhone':'4807363272','identificationType':'0','email':'FIRST5.LAST5@TEST.COM','workPhone':'4807363274','firstName':'TEST5FIRST','homeAddressStreet':'8000','homeAddressState':'AZ'}]";

JavaScript 或 AngularJS 中是否有一个函数可以让我构建一个像这样的真正的 JavaScript 数组?:

var realArray = [
{
"middleName":"T",
"lastName":"TEST1LAST",
"occupation":"HR",
...
},
{
"middleName":"T",
"lastName":"TEST5LAST",
"occupation":"QA",
...
},
...
];

最佳答案

试试这个。

realArray = JSON.parse(stringArray);

关于javascript - 如何在 JavaScript 或 AngularJS 中从数组字符串获取数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38750706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com