Is there a built-in function available that can help convert database search result objects to JSON strings? Or if it doesn’t exist, can we loop to extract each column from the database search result object rows?
You can store the DB results in a variable and apply a function to do the same.
Can you give me an example script? or can you provide a link to the documentation on how to achieve it?
The example shows how to retrieve manually defined column values.
The problem is that we have many database tables which have different columns, can we do a loop function to get each column name and value? so we don’t need to create separate function for each table.
@leo9snake Can you also expand on use case here
What are you trying to achieve (of which this action is a solution)
Hi,
I am trying to convert database search result object into JSON string format or simple string.
For example, let’s say database X has columns X1 - X2 - X3 - … - X12, then what I want to achieve is to transform those columns into a form like:
{
“X1”: “X1 value”,
“X2”: “X2 value”,
“X3”: “X3 value”,
…
“X12”: “X12 value”,
}
I’m thinking of creating a function with a loop (for…, or each…) so I can use it in multiple databases.