Skip to content

faradaytrs/array-to-object-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Transform array to key-value object

Transform array with keys and values to key-value object.

Use cases

You have data in the following format:

[
  {
    "key": "key1",
    "value": "value1"
  },
  {
    "key": "key2",
    "value": "value2"
  }
]

And you need to transform it to the following:

{
  "key1": "value1",
  "key2": "value2"
}

Workflow YAML

- name: Array to Object Action
  uses: faradaytrs/array-to-object-action@v1.0.0
  with:

    # Array to transform
    data: ${{ toJSON(myArray) }}

    # Key property in array
    keyProperty: key

    # Value property in array
    valueProperty: value

    # Output name, defaults to "data"
    output: data

About

Array to object github action

Resources

Stars

Watchers

Forks

Packages

No packages published