如何在JavaScript中拆分数据数组
$index = array_flip(array_map(function($val){
return $val["fieldId"];
}, $arr));
echo $index["ORStreet"];
// output: 11
更改为
{x:30, y:45, x:36, y:49}
?
我需要此表格才能将坐标传递给SVG折线。我找到了一种名为[30, 45, 36, 49]
的方法,但我不知道如何使用它。
答案 0 :(得分:1)
您的对象重复键,这在javascript中是不允许的。映射功能适用于数组而不适用于对象。
如果您有一个键为x,y,z的对象,则可以使用{
"name": "[concat(parameters('factoryName'), '/Veh_Obj')]",
"type": "Microsoft.DataFactory/factories/datasets",
"apiVersion": "2018-06-01",
"properties": {
"linkedServiceName": {
"referenceName": "AzureDataLakeStore1",
"type": "LinkedServiceReference"
},
"annotations": [],
"type": "AzureDataLakeStoreFile",
"structure": [
{
"name": "TBL_ID",
"type": "int"
},
{
"name": "SYS_ADD_DATE",
"type": "date"
},
{
"name": "SYS_CHG_DATE",
"type": "date"
},
{
"name": "CODE",
"type": "string"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
},
{
"name": "Need to remove this value pair",
"type": "Need to remove this value pair"
}
],
"typeProperties": {
"format": {
"type": "TextFormat",
"columnDelimiter": "|",
"rowDelimiter": "",
"quoteChar": "\"",
"nullValue": "\"\"",
"encodingName": null,
"treatEmptyAsNull": true,
"skipLineCount": 0,
"firstRowAsHeader": false
},
"fileName": "[parameters('Veh_Obj_properties_typeProperties_fileName')]",
"folderPath": "[parameters('Veh_Obj_properties_typeProperties_folderPath')]"
}
},
"dependsOn": [
"[concat(variables('factoryId'), '/linkedServices/AzureDataLakeStore1')]"
]
}
将其转换为数组
Object.values
但是,如果您想构造一条折线,则将具有如下所示的数组:
const obj = {x:30, y:45, z:36};
//outputs: [30, 45, 36]
console.log(Object.values(obj));
然后您将获得map方法。您可以执行以下操作:
[{x:30, y:45},{x:36, y:49}]