Extract json key

hi all,
when i request my ticket manager i receive “objects” wich is a list of user request
i got a problem to correctly extract this list
i try :

return [{json:[items.objects]}];

but it return null

thanks for help

[
 [
  null
 ]
]
[
    {
        "objects": {
            "UserRequest::21135": {
                "code": 0,
                "message": "",
                "class": "UserRequest",
                "key": "21135",
                "fields": {
                    "ref": "R-021135",
                    "caller_id_friendlyname": "Denis BAX",
                    "title": "IMPRIMANTE C600I GROS BOURRAGE",
                    "description": "<div>Bonjour,<br><div>GROS BOURRAGE SUR LA C600I</div><div>IL FAUDRAIT DEBOITER LE MODULE DE SORTIE POUR POUVOIR RETIRER LES FEUILLES</div><div>Denis <br></div></div>"
                }
            },
            "UserRequest::21134": {
                "code": 0,
                "message": "",
                "class": "UserRequest",
                "key": "21134",
                "fields": {
                    "ref": "R-021134",
                    "caller_id_friendlyname": "Laurent COURBIN",
                    "title": "installation CK65",
                    "description": "<p>livraison des nouveaux terminaux radios</p>"
                }
            },
            "UserRequest::21132": {
                "code": 0,
                "message": "",
                "class": "UserRequest",
... 

Probably best to read up on the n8n data structure:


and the Function-Node documentation:

Sadly is currently not very intuitive.

I guess what you want is maybe something like this?

return [
	{
		json: items[0].json.objects
	}
];

:slightly_smiling_face:
I use talend ETL a lot but in n8n the output of each node is miraculoumagic something for me !! how items is generated ? Why json between items[0] and objects ?
my knowledge of json and js manipulation are very limited.

So, thanks for the answer, i now have another problem
now, i got one item, and need a list of item to send them to a trello component. i look at your snippet, but found nothing i can use
thanks for help

The answer to your question why there is json in between you find in the Data Structure documentation I linked above. Not sure I understand the part how an item is generated.

Yes to do what you want to do the output is currently not very helpful. Then you should better use the following code that each object is its own item:

const newItems = [];

for (const key in items[0].json.objects) {
  newItems.push({json: items[0].json.objects[key] });
}

return newItems;

Here an example workflow with your data that will create a new Trelle Card for each:

{
  "nodes": [
    {
      "parameters": {
        "listId": "1234",
        "name": "={{$json[\"fields\"][\"title\"]}}",
        "description": "={{$json[\"fields\"][\"description\"]}}",
        "additionalFields": {}
      },
      "name": "Trello",
      "type": "n8n-nodes-base.trello",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "items[0].json = {\n        \"objects\": {\n            \"UserRequest::21135\": {\n                \"code\": 0,\n                \"message\": \"\",\n                \"class\": \"UserRequest\",\n                \"key\": \"21135\",\n                \"fields\": {\n                    \"ref\": \"R-021135\",\n                    \"caller_id_friendlyname\": \"Denis BAX\",\n                    \"title\": \"IMPRIMANTE C600I GROS BOURRAGE\",\n                    \"description\": \"<div>Bonjour,<br><div>GROS BOURRAGE SUR LA C600I</div><div>IL FAUDRAIT DEBOITER LE MODULE DE SORTIE POUR POUVOIR RETIRER LES FEUILLES</div><div>Denis <br></div></div>\"\n                }\n            },\n            \"UserRequest::21134\": {\n                \"code\": 0,\n                \"message\": \"\",\n                \"class\": \"UserRequest\",\n                \"key\": \"21134\",\n                \"fields\": {\n                    \"ref\": \"R-021134\",\n                    \"caller_id_friendlyname\": \"Laurent COURBIN\",\n                    \"title\": \"installation CK65\",\n                    \"description\": \"<p>livraison des nouveaux terminaux radios</p>\"\n                }\n            },\n        },\n    };\nreturn items;"
      },
      "name": "Mock Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const newItems = [];\n\nfor (const key in items[0].json.objects) {\n  newItems.push({json: items[0].json.objects[key] });\n}\n\nreturn newItems;\n"
      },
      "name": "Transform Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    }
  ],
  "connections": {
    "Mock Data": {
      "main": [
        [
          {
            "node": "Transform Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Data": {
      "main": [
        [
          {
            "node": "Trello",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}