Malformed JSON, bug?

Hi,
I have a JSON, that sometimes it resolves in having first value as empty or just a set of values, via a “Merge node-Append”, when I then want to add after “SET” and keep only certain values, I cannot select “Street” and “Age” for example as below.

I only get the option of [item:0] to select in the “SET” and not the usual “Output” Data to select what I want to keep. I believe this is a malformed JSON? How to amend this? Thank you.

image

[
  {
  },
  {
    "name": "John",
    "Street": "John pizza,
    "Age": "25"
  },
  {
    "name": "Joanne spaghetti",
    "Street": "Valkenburgerstraat",
    "Age": "25"
  },

or

[
  {
    "name": "Mary"
  },
  {
    "name": "John",
    "Street": "John pizza,
    "Age": "25"
  },
  {
    "name": "Joanne spaghetti",
    "Street": "Valkenburgerstraat",
    "Age": "25"
  },

It expressions editor uses the data of the first item for reference. Meaning that if the first item is empty, the expression editor will be empty.

Either way, you can still reference the data. In the JSON viewer, select the property you want to reference and copy the ‘parameter path.’ Then, use that value as the expression.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      \n    }\n  },\n    {\n    json: {\n        name: 'ricardo'\n    }\n  }\n]"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        530,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "name_set",
              "value": "={{ $node[\"Function\"].json[\"name\"] }}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        780,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
2 Likes

Thanks a mil :slight_smile:, I had no idea you could use that, that icon is like an easter egg :smiley:.