JsonCompare
Compares two Json strings
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT *
FROM SQLHTTP.net.JsonCompare( @Json1, @Json2 )
Name | Type | Description |
---|---|---|
@Json1 | nvarchar(MAX) | First Json String to be compared |
@Json2 | nvarchar(MAX) | Second Json String to be compared |
bit
0 = The two Json strings ARE NOT the same.
1 = The two Json strings ARE the same.
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 35 36 37 |
DECLARE @Json1 nvarchar(MAX) DECLARE @Json2 nvarchar(MAX) SET @Json1 = '{"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}' SET @Json2 = '{ "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.JsonCompare(@Json1, @Json2) |
1 2 3 4 5 |
----- 1 |