How to convert SQL Output into JSON format

  • Goal: Convert SQL Query result into JSON Objects. Here is an example of what i mean.

What I currently have:

What I want:
Screenshot 2024-09-14 at 7.08.41 PM

  • Steps: Guessing i need to transform the result using JS somehow, just havn't worked with Javascript that much.

  • Details: Ultimately, I want to pass that JSON data through an API. This would also ideally be displayed in the JSON editor prior to passing it through an API.

Hey @alessyl

You can use the method below to get a json string and pass through to an API.

const jsonString = JSON.stringify(data);

What you want to do is turn on Transform results for the DB query, and then use this builtin "retool" method.

Paste in return formatDataAsArray(data); and you will get back the format you want.

1 Like

this worked, thanks!

1 Like