English 中文(简体)
从物体的物体中建立阵列
原标题:Create an array from an object of objects

我试图建立一个我能够穿透的可用阵列。

JSON开始这样做:

"body": {
        "count": 116,
        "value": [
            {
                "id": 1,
                "workItemId": 23515,
                "rev": 1,
                "revisedBy": {
                    "id": "redacted",
                    "name": "redacted",
                    "displayName": "redacted",
                    "url": "redacted",
                    "_links": {
                        "avatar": {
                            "href": "redacted"
                        }
                    },
                    "uniqueName": "redacted",
                    "imageUrl": "redacted",
                    "descriptor": "redacted"
                },
                "revisedDate": "2023-11-30T16:32:00.577Z",
                "fields": {
                    "System.Id": {
                        "newValue": 23515
                    },
                    "System.AreaId": {
                        "newValue": 234
                    },
                    "System.NodeName": {
                        "newValue": "DevOps"
                    },
                    "System.AreaLevel1": {
                        "newValue": "Contoso"
                    },
                    "System.AreaLevel2": {
                        "newValue": "Shared Services"
                    },
                    "System.AreaLevel3": {
                        "newValue": "DevOps"
                    },
                    "System.Rev": {
                        "newValue": 1
                    },
                    "System.AuthorizedDate": {
                        "newValue": "2023-11-30T16:32:00.16Z"
                    },
                    "System.RevisedDate": {
                        "newValue": "2023-11-30T16:32:00.577Z"
                    },
                    "System.IterationId": {
                        "newValue": 203
                    },
                    "System.IterationLevel1": {
                        "newValue": "Contoso"
                    },
                    "System.IterationLevel2": {
                        "newValue": "2023Q4"
                    },
                    "System.WorkItemType": {
                        "newValue": "User Story"
                    },
                    "System.State": {
                        "newValue": "New"
                    },
                    "System.Reason": {
                        "newValue": "New"
                    },
                    "System.AssignedTo": {},
                    "System.CreatedDate": {
                        "newValue": "2023-11-30T16:32:00.16Z"
                    },
                    "System.CreatedBy": {
                        "newValue": {
                            "displayName": "redacted",
                            "url": "redacted",
                            "_links": {
                                "avatar": {
                                    "href": "redacted"
                                }
                            },
                            "id": "redacted",
                            "uniqueName": "redacted",
                            "imageUrl": "redacted",
                            "descriptor": "redacted"
                        }
                    }
                 }
              ]
          }

Im试图通过每个钥匙创造一系列田地和通道。

如果我利用创造力功能来启动一个变量,那么我就认为:

            "value": [
                {
                    "System.AreaId": {
                        "oldValue": 233,
                        "newValue": 234
                    },
                    "System.AreaPath": {
                        "oldValue": "IPFS\Shared Services\Database",
                        "newValue": "IPFS\Shared Services\DevOps"
                    },
                    "System.NodeName": {
                        "oldValue": "Database",
                        "newValue": "DevOps"
                    },
                    "System.AreaLevel3": {
                        "oldValue": "Database",
                        "newValue": "DevOps"
                    },
                    "System.Rev": {
                        "oldValue": 113,
                        "newValue": 114
                    },
                    "System.AuthorizedDate": {
                        "oldValue": "2023-12-22T13:15:14.493Z",
                        "newValue": "2023-12-22T13:34:31.793Z"
                    },
                    "System.RevisedDate": {
                        "oldValue": "2023-12-22T13:34:31.793Z",
                        "newValue": "9999-01-01T00:00:00Z"
                    },
                    "System.ChangedDate": {
                        "oldValue": "2023-12-22T13:15:14.493Z",
                        "newValue": "2023-12-22T13:34:31.793Z"
                    },
                    "System.Watermark": {
                        "oldValue": 126007,
                        "newValue": 126014
                    },
                    "System.BoardLane": {
                        "newValue": "ADO Automation"
                    },
                    "WEF_292A6CA8129248189CA52399E366EBC5_System.ExtensionMarker": {
                        "oldValue": false,
                        "newValue": true
                    },
                    "WEF_B8D7CB8BBE4B44ABB66660A5EDCCB21E_System.ExtensionMarker": {
                        "oldValue": true,
                        "newValue": false
                    },
                    "WEF_C63F4704F90D431A8B59108A6997DBEE_System.ExtensionMarker": {
                        "oldValue": true,
                        "newValue": false
                    }
                }
            ]

这产生了一个单一指数。 下面是:

            "value": [
                    "System.AreaId": {
                        "oldValue": 233,
                        "newValue": 234
                    },
                    "System.AreaPath": {
                        "oldValue": "IPFS\Shared Services\Database",
                        "newValue": "IPFS\Shared Services\DevOps"
                    },
                    "System.NodeName": {
                        "oldValue": "Database",
                        "newValue": "DevOps"
                    },
                    "System.AreaLevel3": {
                        "oldValue": "Database",
                        "newValue": "DevOps"
                    },
                    "System.Rev": {
                        "oldValue": 113,
                        "newValue": 114
                    },
                    "System.AuthorizedDate": {
                        "oldValue": "2023-12-22T13:15:14.493Z",
                        "newValue": "2023-12-22T13:34:31.793Z"
                    },
                    "System.RevisedDate": {
                        "oldValue": "2023-12-22T13:34:31.793Z",
                        "newValue": "9999-01-01T00:00:00Z"
                    },
                    "System.ChangedDate": {
                        "oldValue": "2023-12-22T13:15:14.493Z",
                        "newValue": "2023-12-22T13:34:31.793Z"
                    },
                    "System.Watermark": {
                        "oldValue": 126007,
                        "newValue": 126014
                    },
                    "System.BoardLane": {
                        "newValue": "ADO Automation"
                    },
                    "WEF_292A6CA8129248189CA52399E366EBC5_System.ExtensionMarker": {
                        "oldValue": false,
                        "newValue": true
                    },
                    "WEF_B8D7CB8BBE4B44ABB66660A5EDCCB21E_System.ExtensionMarker": {
                        "oldValue": true,
                        "newValue": false
                    },
                    "WEF_C63F4704F90D431A8B59108A6997DBEE_System.ExtensionMarker": {
                        "oldValue": true,
                        "newValue": false
                    }
               ]

如何做到这一点的想法?

问题回答

你提供的数据最初与你使用<代码>createArray()”时的结果没有什么不同,但除此以外,如果你想要一种(相对而言)简单的方法,你可以使用<代码>。 Json Property to name Value Pair Array operation within Advanced Data Operationslinkor.

连接器价格相当可承受,拥有大量业务选择。

https://statesolutions.com.au/json-properties-to-name-value-pair-array/

https://statesolutions.com.au/pricing/

这就是你随后能够掌握并做你所需要的数据集。

[
  {
    "propertyName": "System.AreaId",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Integer",
        "propertyValue": 234
      }
    ]
  },
  {
    "propertyName": "System.AreaLevel1",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "Contoso"
      }
    ]
  },
  {
    "propertyName": "System.AreaLevel2",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "Shared Services"
      }
    ]
  },
  {
    "propertyName": "System.AreaLevel3",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "DevOps"
      }
    ]
  },
  {
    "propertyName": "System.AssignedTo",
    "propertyType": "Object",
    "propertyValue": []
  },
  {
    "propertyName": "System.AuthorizedDate",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Date",
        "propertyValue": "2023-11-30T16:32:00.16Z"
      }
    ]
  },
  {
    "propertyName": "System.CreatedBy",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Object",
        "propertyValue": [
          {
            "propertyName": "_links",
            "propertyType": "Object",
            "propertyValue": [
              {
                "propertyName": "avatar",
                "propertyType": "Object",
                "propertyValue": [
                  {
                    "propertyName": "href",
                    "propertyType": "String",
                    "propertyValue": "redacted"
                  }
                ]
              }
            ]
          },
          {
            "propertyName": "descriptor",
            "propertyType": "String",
            "propertyValue": "redacted"
          },
          {
            "propertyName": "displayName",
            "propertyType": "String",
            "propertyValue": "redacted"
          },
          {
            "propertyName": "id",
            "propertyType": "String",
            "propertyValue": "redacted"
          },
          {
            "propertyName": "imageUrl",
            "propertyType": "String",
            "propertyValue": "redacted"
          },
          {
            "propertyName": "uniqueName",
            "propertyType": "String",
            "propertyValue": "redacted"
          },
          {
            "propertyName": "url",
            "propertyType": "String",
            "propertyValue": "redacted"
          }
        ]
      }
    ]
  },
  {
    "propertyName": "System.CreatedDate",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Date",
        "propertyValue": "2023-11-30T16:32:00.16Z"
      }
    ]
  },
  {
    "propertyName": "System.Id",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Integer",
        "propertyValue": 23515
      }
    ]
  },
  {
    "propertyName": "System.IterationId",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Integer",
        "propertyValue": 203
      }
    ]
  },
  {
    "propertyName": "System.IterationLevel1",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "Contoso"
      }
    ]
  },
  {
    "propertyName": "System.IterationLevel2",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "2023Q4"
      }
    ]
  },
  {
    "propertyName": "System.NodeName",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "DevOps"
      }
    ]
  },
  {
    "propertyName": "System.Reason",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "New"
      }
    ]
  },
  {
    "propertyName": "System.Rev",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Integer",
        "propertyValue": 1
      }
    ]
  },
  {
    "propertyName": "System.RevisedDate",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "Date",
        "propertyValue": "2023-11-30T16:32:00.577Z"
      }
    ]
  },
  {
    "propertyName": "System.State",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "New"
      }
    ]
  },
  {
    "propertyName": "System.WorkItemType",
    "propertyType": "Object",
    "propertyValue": [
      {
        "propertyName": "newValue",
        "propertyType": "String",
        "propertyValue": "User Story"
      }
    ]
  }
]

......您可使用<代码>Select操作,进一步将每个项目削减至只剩下您想要的财产。

如果你想在不采取额外步骤的情况下进一步细分,你(或我可以帮助你)也可以撰写一些C#代码并使用<代码>。 Execute C# operation from within the same connectionor.

www.un.org/Depts/DGACM/index_spanish.htm 这里,你可以如何创造理想的田地,并通过每个钥匙加以利用,假设你重新使用 Java贝:。

  1. www.un.org/Depts/DGACM/index_spanish.htm 进入“价值”阵列中的“现场”物体:

    const fieldsArray = body.value.map(item => item.fields);
    
  2. www.un.org/Depts/DGACM/index_spanish.htm a. 将物体阵列成一阵列:

    const flattenedFields = [];
    for (const fields of fieldsArray) {
        for (const [key, value] of Object.entries(fields)) {
            flattenedFields.push({ [key]: value });
        }
    }
    
  3. www.un.org/Depts/DGACM/index_spanish.htm 现在,你有理想的格式:。

    console.log(flattenedFields);
    [
        { "System.AreaId": { "newValue": 23515 } },
        { "System.NodeName": { "newValue": "DevOps" } },
    ]
    
  4. www.un.org/Depts/DGACM/index_spanish.htm 每一关键值的配对:

    for (const field of flattenedFields) {
        const fieldName = Object.keys(field)[0]; // Get the field name
        const fieldValue = field[fieldName]; // Get the field value
        console.log(fieldName, fieldValue);
    }
    

Explanation:

  1. The map method creates a new array (fieldsArray) by extracting the "fields" object from each item in the original "value" array.
  2. The nested loops iterate through each fields object and its key-value pairs, pushing them as individual objects into flattenedFields.
  3. The Object.entries method is used to get key-value pairs from the fields objects.
  4. The final loop demonstrates how to access the field name and value within each key-value pair.




相关问题
How to get File Size from http request to SharePoint

In my http request to SharePoint block, I want to show the file size field as the image above, however I can t really find what should be the name of it. I have tried something like $select=FileSize ...

DocuSign - Sharepoint List integration

Hello I m currently stuck creating a powerautomate flow between DocuSign and MS lists. I m working on a project and I need for our employees to complete that Docusign form and for the information on ...

Dynamics 365 FetchXML nested link-entity, not-in

It s a long shot, but in FetchXML I have an entity with a many-to-many relationship with another table. In short, the Contact entity is linked with the ConnectionRole entity through an intermediary ...

热门标签