FOR JSON (Pretty Path)

yosiasz showed this trick to convert table fields back into XML and it is also in pretty path too when I click on the field.

SELECT * FROM #TEMPTable
FOR XML PATH ('ParameterValue'), root ('ParameterValues');  

When I tried to do this with JSON, it returns the correct JSON but it does not pretty path (indent). Is this possible with JSON?

SELECT * FROM #TEMPTable
FOR JSON PATH ('ParameterValue'), root ('ParameterValues');

Not in SSMS, but there are free online sites that will format JSON for you.

1 Like