I have an app that needs to be supplied with configuration data as key value pairs in JSON.
I want to output JSON of key value pairs from a table query.
The table can have different named items and varying quanities of items.
TABLE
| ITEMID | REPORTID | NAME | VALUE |
|---|---|---|---|
| 1 | 29 | caption | Profit by Product |
| 2 | 29 | bgColor | #FFFFFF |
| 3 | 29 | showBorder | 0 |
| 4 | 29 | showsum | 0 |
SQL
select ................. FOR JSON PATH
I'm guessing this needs to use a PIVOT?
Expected JSON
{"caption":"Profit by Product","bgColor":"#FFFFFF","showBorder":"0","showsum":"0"}
Appreciate help anyone can provide.
