bradwyatt
5 years agoNew Contributor II
How to Transform SQL Server Records to JSON usable format
I am querying transactions_table and batch_table using SQL Server Execute snap. The batch_table returns 1 record, and in this example the transactions_table returns 2 records. I need to be able to pull the data into a JSON-format that is compatible with my company’s API.
Below is an example format. The “interface” key’s values are manually entered by me. The “batch_table” key contains the values from the one record in the batch_table from SQL Server. The “transactions_table” key contains a list of all the records from the transactions_table.
What would be the most efficient way of implementing this?
{
"interface" : {
"type" : "INVOICE",
"client": SQLServer
},
"data": {
"batch_table": {
"BATCH_ID": 1
},
"transactions_table": [{
"TRANSACTION_ID": 1,
"AMOUNT": 5.90
},
{
"TRANSACTION_ID": 2,
"AMOUNT: 11.20
}]
}
}