在JavaScript中,我向服务器发送https请求。我收到了我正在寻找的数据,但它是批量生产的。根据我要求的数据大小,可能有2-50个不同的批次。我需要将它们全部放在一起,这样我就可以解析并从数组中提取所需的数据。我收到的数据粘贴在下面。您可以看到在第一批的开头有一个日期和时间戳,在“行”之后有另一个:这些是由我正在使用的调试器添加的,这就是我知道它们是分开来的。我的问题是:
1)我如何将字符串连接在一起
2)获取数组的最佳方式是哪种,以便我可以选择我想要的数据?
2018 - 03 - 08 T21: 09: 18.913 Z f657fe40 - 2314 - 11e8 - 8273 - 19289 d6ed567 {
"id": 12345678,
"name": "Dummy sheet",
"version": 1,
"totalRowCount": 1,
"accessLevel": "ADMIN",
"effectiveAttachmentOptions": ["BOX_COM", "GOOGLE_DRIVE", "FILE", "EGNYTE", "ONEDRIVE", "DROPBOX", "EVERNOTE"],
"ganttEnabled": false,
"dependenciesEnabled": false,
"resourceManagementEnabled": false,
"cellImageUploadEnabled": true,
"userSettings": {
"criticalPathEnabled": false,
"displaySummaryTasks": true
},
"permalink": "https://app.smartsheet.com/b/home?lx=rxeuvsB26BVmyEpa6OYxUA",
"createdAt": "2018-03-06T14:29:32Z",
"modifiedAt": "2018-03-06T14:51:59Z",
"columns": [{
"id": 3114821425096580,
"index": 0,
"title": "Primary Column",
"type": "TEXT_NUMBER",
"primary": true,
"validation": false,
"width": 150
}, {
"id": 7618421052467076,
"index": 1,
"title": "Column2",
"type": "TEXT_NUMBER",
"validation": false,
"width": 150
}, {
"id": 1988921518253956,
"index": 2,
"title": "Column3",
"type": "TEXT_NUMBER",
"validation": false,
"width": 150
}, {
"id": 6492521145624452,
"index": 3,
"title": "Column4",
"type": "TEXT_NUMBER",
"validation": false,
"width": 150
}, {
"id": 4240721331939204,
"index": 4,
"title": "Column5",
"type": "TEXT_NUMBER",
"validation": false,
"width": 150
}, {
"id": 8744320959309700,
"index": 5,
"title": "Column6",
"type": "TEXT_NUMBER",
"validation": false,
"width": 150
}],
"rows": 2018 - 03 - 08 T21: 09: 18.932 Z f657fe40 - 2314 - 11e8 - 8273 - 19289 d6ed567[{
"id": 573049024079748,
"rowNumber": 1,
"expanded": true,
"createdAt": "2018-03-06T14:51:59Z",
"modifiedAt": "2018-03-06T14:51:59Z",
"cells": [{
"columnId": 3114821425096580,
"value": 123456.0,
"displayValue": "$123,456.00"
}, {
"columnId": 7618421052467076
}, {
"columnId": 1988921518253956
}, {
"columnId": 6492521145624452
}, {
"columnId": 4240721331939204
}, {
"columnId": 8744320959309700
}]
}]
}
答案 0 :(得分:0)
很难从您的描述中判断出您尝试连接哪些字符串 - 整个JSON blob,JSON中的某些字符串?
我至少可以说连接字符串的有效方法是将它们全部推入数组,然后将join
数组转换为一个字符串。
var builder = [];
builder.push(string1);
builder.push(string2);
builder.push(string3);
...
var result = builder.join('');
我不确定你的意思是"进入一个数组"或者,如果你正在谈论将所有一个字符串转换为一个数组,每个字符作为一个单独的项目,string.split('')
将会这样做。