对象可以处理多少个键值对?

问题描述 投票:-3回答:1

我有300万个引导对象和5千个程序对象,它们将使用程序活动映射在一起,因此引导对象将具有多个程序对象。所以我的问题是,我可以存储300万条线索,将程序保存在一个对象中吗?

例如:

{
     "lead78354": {
         "First Name": "test",
         "Last Name": "test",
         "Id": "78354",
         "Email Address": "[email protected]",
         "FirstLeadSource": "null",
         "leadStatus": "Qualified",
         "country": "US",
         "SEInferredCountry": "null",
         "LastProgramSuccess": "null",
         "HistoryOfProgramSuccesses": "Dec 14, 2017 : US_All_Contact_Sale",
         "programs": {
             "program1": {
                 "id": 1324,
                 "description": "•\tContent selection  LP & TY",
                 "createdAt": "2015-02-27T15:18:31Z+0000",
                 "updatedAt": "2017-12-17T15:09:39Z+0000",
                 "type": "Default",
                 "channel": "Content",
                 "folder": {
                     "type": "Folder",
                     "value": 7685,
                     "folderName": "US Country Pages"
                 },
                 "status": "",
                 "workspace": "NAM",
                 "tags": [{
                     "tagType": "Marketing Campaign",
                     "tagValue": "EcoBuildings"
                 }, {
                     "tagType": "Primary Business",
                     "tagValue": "All Business Units"
                 }, {
                     "tagType": "Primary Country",
                     "tagValue": "US"
                 }, {
                     "tagType": "Primary Market Segmentation",
                     "tagValue": "All Segments"
                 }],
                 "costs": []
             }
         }
     },
     lead2:{
            "test":"test"
            programs:{.......}
     }
   so on....
}
javascript json
1个回答
1
投票

是的你可以。您所要做的就是创建一个对象,然后添加具有唯一ID的新对象。我在下面添加了一个片段。这里唯一的限制似乎是你的RAM。

var allobjects = {};
var sampleObj = {
         "First Name": "test",
         "Last Name": "test",
         "Id": "78354",
         "Email Address": "[email protected]",
         "FirstLeadSource": "null",
         "leadStatus": "Qualified",
         "country": "US",
         "SEInferredCountry": "null",
         "LastProgramSuccess": "null",
         "HistoryOfProgramSuccesses": "Dec 14, 2017 : US_All_Contact_Sale",
         "programs": {
             "program1": {
                 "id": 1324,
                 "description": "•\tContent selection  LP & TY",
                 "createdAt": "2015-02-27T15:18:31Z+0000",
                 "updatedAt": "2017-12-17T15:09:39Z+0000",
                 "type": "Default",
                 "channel": "Content",
                 "folder": {
                     "type": "Folder",
                     "value": 7685,
                     "folderName": "US Country Pages"
                 },
                 "status": "",
                 "workspace": "NAM",
                 "tags": [{
                     "tagType": "Marketing Campaign",
                     "tagValue": "EcoBuildings"
                 }, {
                     "tagType": "Primary Business",
                     "tagValue": "All Business Units"
                 }, {
                     "tagType": "Primary Country",
                     "tagValue": "US"
                 }, {
                     "tagType": "Primary Market Segmentation",
                     "tagValue": "All Segments"
                 }],
                 "costs": []
             }
         }
     };
     
 for (var i=0;i<3000000;i++) {
  allobjects[("lead"+i)]=Object.create(sampleObj);
 }
 
 var count =0;
 for (var prop in allobjects) {
 count++;
 }
 console.log("lead count: " + count);
© www.soinside.com 2019 - 2024. All rights reserved.