Display JSON Objects as key+value and send via SMTP Email

Hey everybody,

I’ve been breaking my head over this, so I hope you can help me.

I’m trying to turn the received JSON Object data into a string of “key: value” and send it via SMTP email.

What do I mean exactly?
I receive this data via Webflow Webhook, and I want to know if there is a command that I can run (whether it’s a function node, or to add something to the {{$node[“Webflow Trigger”].json[“data”]}} tag which will allow to:

  1. Extract only the Key and the Value (without anything additional as the brackets [] or the “Object” string).

  2. Turn them into individual lines, so that when I enter it into the HTML Text field in the SMTP email node, it will display on individual lines, and will email that easy to understand data.


So in the illustration above, you can see how the raw data value is all joined together, and it has other attributes such as brackets and the “Object” syntax.

Any help is highly appreciated, whether it’s theories to a solution or the solution itself.

Thank you in advance!

Hi @itsalanlee ,
welcome to the community :tada:

I am not entirely sure what your current workflow looks like, but I tried to parse incoming json into a key: value string using either a Set or a Function Node.

The Set Node is using expressions to create a string message:

The Function Node is using JSON.stringify() and string.replace(regex) to convert all json key value pairs.

image

My example workflow:

2 Likes

Marcus, if nobody has ever told you this before, know that you my friend, are a legend!

That Function Node solution came in a clutch, exactly what I was looking for:
The data gets converted to a string and when inputted as an expression within its child node, the keys and their values get displayed properly with the line breaks.

I’m trying to push this into the Email node and use the whole HTML Text aspect of it to see if it’s possible to style the data as well, but I don’t know how do-able that is yet.

But you have definitely helped answer my biggest question and concern, thank you!!

1 Like

Thanks, glad I could help :smile:

1 Like