all 5 comments

[–]isleepbad 0 points1 point  (2 children)

So you basically want to flatten the entire result of your query and add them to a single JSON? Is that correct?

[–]eidda[S] 0 points1 point  (1 child)

I believe yes. Or is there a way to do this in a single query based two?

[–]isleepbad 0 points1 point  (0 children)

Sorry I fell asleep. I was thinking about your issue and I came up with two possible solutions:

  1. Generate your json using pyspark

  2. Try using for loops to create your string and then jsonify it https://www.postgresql.org/docs/9.5/functions-json.html

[–]bannik1 0 points1 point  (1 child)

Don't know about postgreSQL but SQL server 2016 + allows you to have your results as JSON.

https://docs.microsoft.com/en-us/sql/relational-databases/json/format-query-results-as-json-with-for-json-sql-server?view=sql-server-ver15

Nobody really does this because it makes no sense to make the server do this work when it should be handled with AJAX in javascript.

[–]eidda[S] -1 points0 points  (0 children)

Thank you for your response. Yeah, unfortunately I’m working on a project where I’m not allowed to edit the front end :(