Separating JSON response data

Describe the issue/error/question

I want to take the items in this array (below) and treat them separately. Using Function node, I am unable to figure out how to piece this data apart. No typical method of addressing the data using JSON key/value objects is working. JavaScript Code Snippets | Docs this JS snippet didn’t work.

Problem executing workflow

Share the output returned by the last node

NOTE: THIS IS OUTPUT FROM POSTMAN, NOT N8N, IT ALREADY HAS AN ‘items’ KEY

{
    "items": [
        {
            "id": "a2FsZWItaG9zdGVkOjVlNzM5YzFlMWY4YmRiMjBlOTFmMDI0NzYzMTM3NThm",
            "repository": "kaleb-hosted",
            "format": "docker",
            "group": null,
            "name": "jupyterhubimage_hub/cache",
            "version": "b25059f8289b75594eda88fc7fda254a626606c383479fbcec63e19d9ff95558",
            "assets": [
                {
                    "downloadUrl": "http://165.237.158.24:8081/repository/kaleb-hosted/v2/jupyterhubimage_hub/cache/manifests/b25059f8289b75594eda88fc7fda254a626606c383479fbcec63e19d9ff95558",
                    "path": "v2/jupyterhubimage_hub/cache/manifests/b25059f8289b75594eda88fc7fda254a626606c383479fbcec63e19d9ff95558",
                    "id": "a2FsZWItaG9zdGVkOjIxMDMxZGZhZjQ1ZTViNTg3ZDc4ZDUzOWQ5MjhkMGY0",
                    "repository": "kaleb-hosted",
                    "format": "docker",
                    "checksum": {
                        "sha1": "5ef07dbbc9b479a5dcac07ba365881ddc4b7d03c",
                        "sha256": "02bd1dd1d08b52ab825e9c6bd46dcb6d72c16828f8d877c605795b24debadf30"
                    },
                    "contentType": "application/vnd.docker.distribution.manifest.v2+json",
                    "lastModified": "2021-09-14T15:58:27.480+00:00"
                }
            ]
        },
        {
            "id": "a2FsZWItaG9zdGVkOjNmNWNhZTAxNzYwMjMzYjZiMzNlMzhmY2E4OWJiNTgz",
            "repository": "kaleb-hosted",
            "format": "docker",
            "group": null,
            "name": "jupyterhubimage_hub/cache",
            "version": "c0f62dea3dac2c00a16c20a33e312efcb30504fcd93eecada926cde7f75c07f5",
            "assets": [
                {
                    "downloadUrl": "http://165.237.158.24:8081/repository/kaleb-hosted/v2/jupyterhubimage_hub/cache/manifests/c0f62dea3dac2c00a16c20a33e312efcb30504fcd93eecada926cde7f75c07f5",
                    "path": "v2/jupyterhubimage_hub/cache/manifests/c0f62dea3dac2c00a16c20a33e312efcb30504fcd93eecada926cde7f75c07f5",
                    "id": "a2FsZWItaG9zdGVkOmUwMTg4ZWQwNzI4ZmE2OGYwZTUyZDUyOTU5MzBkMGUx",
                    "repository": "kaleb-hosted",
                    "format": "docker",
                    "checksum": {
                        "sha1": "72b026cd101f14017b9f3c5b69f320119c2f5cbf",
                        "sha256": "1057e21cd68291c7f79ddd8d22a949ee05e58ea7503a093821ce22b8e9e385e5"
                    },
                    "contentType": "application/vnd.docker.distribution.manifest.v2+json",
                    "lastModified": "2021-09-14T15:58:29.582+00:00"
                }
            ]
        }
    ]
}

Error

ERROR: items[0].json.map is not a function [Line 1]

Information on your n8n setup

  • n8n version: 0.162.0
  • Database you’re using (default: SQLite): Postgres
  • Running n8n with the execution process [own(default), main]: Default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hi @dylan.moore, can you confirm how the data looks in n8n for you? Like so by any chance?

If so, you could use the Item Lists node to split up the data from the items array and would then have individual items each with a field like id, repository, format, group etc.:

Example Workflow

Is this what you had in mind?

Yes, this worked. Thank you :slight_smile:

1 Like