FormatJson
Formats a JSON string to make it nice and readable
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.JsonFormat( @Json )
Name | Type | Description |
---|---|---|
@Json | nvarchar(MAX) | Json string |
nvarchar(MAX)
1 2 3 4 5 6 7 |
DECLARE @Json nvarchar(MAX) SET @Json = '{"firstName": "John","lastName": "Smith","isAlive": true,"age": 25,"address": {"streetAddress": "21 2nd Street","city": "New York","state": "NY","postalCode": "10021-3100"},"phoneNumbers": [{"type": "home","number": "212 555-1234"},{"type": "office","number": "646 555-4567"},{"type": "mobile","number": "123 456-7890"}],"children": [],"spouse": null}' SELECT SQLHTTP.net.FormatJson(@Json) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
---------------------------------------------------- { "firstName": "John", "lastName": "Smith", "isAlive": true, "age": 25, "address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": "10021-3100" }, "phoneNumbers": [ { "type": "home", "number": "212 555-1234" }, { "type": "office", "number": "646 555-4567" }, { "type": "mobile", "number": "123 456-7890" } ], "children": [ ], "spouse": null } |