How to iterate over a nested JSON object

Hello:
I need to iterate over a nested field in a JSON like this:

{
   "date":"2025-04-28",
   "object" :  {
        "temp" : "24",
        "hum" : "49",
        "press" : "10"
     },
    "error":""
}

I’m using a Split Out node, configured to split by the “object” field, but the output looks like this:

{
   "object"  :  "24"
},
{
   "object": "49"
},
{
   "object":  "10"
}

What can I do to replace the "object with the field name to look like this:

 {
        "temp" : "24",
        "hum" : "49",
        "press" : "10"
 }

Thanks in advance

Hello
Good evening.

See this suggestion below.

Before testing, copy your flow and open a new workflow. Paste your flow into this workflow and test the suggestion below to see if it was useful and made sense to you.

Suggestion;

Use a Code NODE to get the entire object field directly from the initial item

// items[0].json é o seu objeto inteiro (com "object" aninhado)

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

If this suggestion solved your problem, mark my post as a solution (blue box with check mark) so that this ongoing discussion does not distract others who want to find out the answer to the original question and press the heart button :heart:. Thank you :+1:

Hi @greg_luis,

I admit I was a bit confused at first as well, but here’s what I discovered:

I think what’s happening is that Split Out only knows how to split arrays, not objects.
So when you point it at this object, it looks like it iterates over its values, re-wrapping each one under the original field name object

To get each key–value pair as its own JSON object (e.g. { "temp": "24" }, { "hum": "49" }, …), you need to convert your single object into an array of one-property objects before splitting. Here’s how:

  1. Add a Set node immediately before your Split Out.
  2. Create a new field called object (type: Array).
  3. Use this expression as the field’s value:
{{ Object.entries($json.object).map(([key, value]) => ({ [key]: value })) }}
  1. Feed the output of that Set node into your Split Out, configured to split on the object field.


Alternatively, you can just bypass Split Out entirely and use Code node to perform the same transformation in code, This will directly output each key–value pair as its own item.