Adding Json Object as a Value to a KeyValue Pair in a Node

Describe the question

How do I add a nested json object into a node as a parameter?

As a user I need to add nested json to a node.
Because the receiving api expects a post to come in with fully formatted deep json.
To be very specific, Iterable is expecting to get an array of tags.
Whenever I add nested Json to a post request the other side gets “objects” instead of properly formatted JSON.
So effectively I cannot seem to send properly formatted deep json. Imaging trying to use a node to send the JSON below.

For example imagine you are using Iterable - Iterable supports json objects as a datatype.
so normally username would come in a a simple KeyValue Pair. And Tags would need to come in as an array or at least formatted JSON

Example of Iterable node configuration. Hitting the endpoint of update user

Key: UserName
Value: Mike
Key: Email
Value: [email protected]
Key: Tags
        "TagName": data,
        "TagDate": data

-OR An Array-
Key: Tags
Value: [  {
              "TagName": data,
              "TagDate": data
              "TagName": data,
              "TagDate": data

And ideally I would be able to build that Tag in a code block, and merge it in similarly to the photos below.
And it seems like the Key is using the expression area to unwrap the object so it can be transmitted as json

What is the error message (if any)?

When I try to add a piece of nested Json to any api call it shows up on the other side as [object]
Examples in photos

Please share the workflow

I cannot really share the workflow because conceptually it is just so small the screenshots are more telling.

Share the output returned by the last node

This is what I am trying to send.

On the other side it shows up looking like this

Information on your n8n setup

  • n8n version:0.179
  • Database you’re using (default: Postgres):
  • Running n8n with the execution process [own(default),]:
  • Running n8n via [Docker]:

I believe you need the Set node for this, output the object into the Set node first and it should output correctly.

If I’m understanding correctly, once you get to deep JSON objects, you might want to use a Function Item node to have full control of the object, or JSON/Raw Parameters for the call to the API and {{JSON.stringify($json["Current_Broker"])}}

@ctrl-freak @djangelic Thankyou for responding! Maybe I was not clear enough in the original post. Does this image clarify the ask? I cannot out put the object to the set node because by the time it is in hands of a receiving service or API they would not know what to do with it.

Maybe this image provides greater clarity on what I am trying to do.

Hi David, would you mind giving us a sample of the values you get? That would help us play with the output and help you resolve this. Otherwise, I would try using the item list node to “extract” the deep json using dot notation. You would just use the split out function and set the key as “Current_Broker”. Let me know if this helps.

Schrodinger’s Bug! I cannot reproduce it! But know I know what was mentioned earlier is expected behavior. I will try to recreate the bug and post on this thread when I have solid steps to reproduce it.

Hi David,

In your JSON.Stringify expression you’ve got Broker capitalised, whereas in your input object it’s lowercase. That’s on me, I didn’t check when I typed it out. You should find if you fix that you’ll at least get JSON out.

It’ll be a string of JSON, so if you then need to pass this onto another service you’ll need to JSON.parse. This is where I think @djangelic’s Set node is the correct suggestion, everything looks like you should be able to just set it directly.

Good luck.

Walk of shame…
Here are two nodes configured with sample data working correctly which shows what when I bumped into this issue before I was either doing something wrong, or it was a bug. When I encounter the issue again I will have a better report.

Code to pass the data

code to receive the data