Removing the 'propertyname' from a json-string

Hey,

I have been using N8N for quite some time now and it has helped me out in a lot of occassions. However now I am hitting dead-end in the thinking process and hopefully someone can point me in the right direction :slight_smile:

Situation:

There are multiple endpoints that need to be called several times (each time for a different user with a different bearer token). I want to merge the user-results of each endpoint to 1 json. This way I can easily import it into my application.

How I am doing this now is:

  1. Get list of users with tokens from MySQL.
  2. Loop through those tokens and connect to the endpoint
  3. Write individual JSON-result to MySQL-table (I use json.stringify)

So far so good. After this process has run, I want to be able to do a GET-request to the N8N-webhook to get the combined JSON data.

  1. First node is MySQL-query which selects all records from the table and does a group_concat to combine them together to 1 big JSON
  2. Feed this info into he Respond to Webhook

The JSON is valid if I check this in a JSON validator. However N8N captures the json in an item which carries the same name as the mysql-field

How can i convert this to a regular json? Like:
image

If I am unclear or you need more info let me know . Thanks in advance :slight_smile:

Workflow

Information on your n8n setup

  • n8n version:0.183.0
  • Database you’re using (default: SQLite): Postgres
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hi @HamzaJ

Welcome to the community!
Not completely sure what you are looking for so I made you 2 examples. See the workflow below. Hope one of them points you in the right direction.

Thanks for the quick response Bram. Im having a bit of a hard time explaining myself

I tried your solution, however it did not work. I think the issue is that my sql-result (which contains the json) is captured between quotes.

Your function generates a nice formatted json:
image

However the item I get from the sql-node is captured between quotes

image
image

Could this be the issue for it not working?

Hamza

Hi @HamzaJ

It’s a bit nasty but this should work I think:

For the people wondering:

Took a bit of a different approach and got a step closer. The http-request is now putted through as string, which is then Json.stringify before stored in a MySQL-DB

Getting the data and putting it in the Respond to Webhook works in most occassion. However sometimes a json-value contains quotes and I need to find out how to escape these and only these:

Example:

"Omschrijving":"text text text "text" text"

Escaping quotes with a replace, replaces all quotes and breaks the json. If someone might have the solution let me know. I will keep tinkering