0
起初我有一個包含字符串數據如何從JavaScript或AngularJS中的數組字符串中獲取數組?
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':'[email protected]','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",
...
},
...
];
你的樣本串具有一個結束']'但沒有開口'[',順便說一句。 –
AngularJS中的原生函數將是['angular.fromJson(stringArray);'](https://docs.angularjs.org/api/ng/function/angular.fromJson) – mzmm56
是的,S McCrohan,你是對的。這是我的錯字。更正它。 –