A 'json' property isn't an object

Hi. I’m getting the same error that was covered here: Returning a array from Code Node - A 'json' property isn't an object – but I’m not sure how to resolve it in this instance

Describe the problem/error/question

I’m getting the “‘json’ property isn’t an object” from JSON objects returned by app integrations

What is the error message (if any)?

A ‘json’ property isn’t an object [item 0]

Please share your workflow

Share the output returned by the last node

[

{

“code”:
0,

“signal”:
null,

“stdout”:
“/var/nas/grandstream/PBX_Recordings_C074AD9F9934/2026-04/auto-1775492898-1112-6053608799.wav”,

“stderr”:
“”

},

{

“code”:
0,

“signal”:
null,

“stdout”:
“/var/nas/grandstream/PBX_Recordings_C074AD9F9934/2026-04/auto-1775504557-1112-6053608799.wav”,

“stderr”:
“”

},

{

“code”:
0,

“signal”:
null,

“stdout”:
“/var/nas/grandstream/PBX_Recordings_C074AD9F9934/2026-04/auto-1775505430-6053608799-1112.wav”,

“stderr”:
“”

}
]

Information on your n8n setup

  • n8n version: 2.2.3
  • Database (default: SQLite): unknown
  • n8n EXECUTIONS_PROCESS setting (default: own, main): unknown
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Docker container

I should also add that this occurs when I try to do a “Run Once for Each Item” code block, and that it occurs with JSON that is returned by the Postgres integration and the SSH integration.

Hi @richardajensen Welcome!
Ummmm… Try this in your code node

// Each input item already has stdout on $json
return [{
  json: {
    directoryStructure: $json.stdout,
  },
}];

Hi – thanks for the quick response.

I’m not a huge fan of this forum software, so I’m sorry if the info I’ve supplied doesn’t exactly capture the error that’s occurring.

What’s happening is that I’m getting an error when I refer to the JSON output from a previous node. Thus, in your example, I’d get an error because it would say that “A ‘json’ property isn’t an object [item 0]”

Here’s a side node that I built that generates the error:

Sorry – those pasted nodes didn’t work – I’m not a huge fan of this forum software.

Here’s the offending JavaScript form the node in question:

const directoryStructure = $json.recordingurl.split('/')

return [{ directoryStructure }]

@richardajensen i think i understood you, but correct me if i am wrong, so i think you should be using the code node’s required structure and then wrap your result in a json object something similar to what you have done, see this example:

const directoryStructure = $json.recordingurl.split('/');
return [{ json: { directoryStructure } }];

so that you do not hit any error like the one you have described.

3 Likes

Wait a minute. I see what you’re saying. The error’s on the output side, not the input side.

Sorry for the additional posts.

1 Like

ah yeah the code node needs to return { json: { ... } } — that’s the shape n8n expects from code nodes. in your case it would be something like return [{ json: { directoryStructure: $json.recordingurl.split('/') } }] instead of just returning the object directly. the error happens because n8n tries to access $json on what you returned, but if you don’t wrap it in { json: ... } it doesnt know how to parse it

1 Like

the issue is that you’re trying to return the data without wrapping it in the item structure. the code node expects you to return items with both json and binary properties. try wrapping your return like this:

return [$json.recordingurl.split(‘/’).map((part, idx) => ({ json: { part, index: idx } }))].flat();

that way each output becomes a separate item the next node can read. the json property gets treated as an object again.

Thanks for the instructions on how to automatically generate the structure, as opposed to looping over the array and building it bit by bit.

I found it easier, in this case, to simply append the data I was extracting to the pre-existing structure, but this is a helpful starting point for cases when constructing a new structure is advantageous or necessary.