JSON data processing in SQL Server

I have a Json string. I want to get the value from this Json string.

This is my json line {"latitude":"22.5712854"},{"longitude":"88.4266847"}

I want only latitude and longitude using a TSQL query.

+4
source share
2 answers

TSQL has no native way to parse JSON. But Phil Factor created his own implementation of JSON processing in an SQL function. Read more about this in a simple talk blog article: Using JSON Strings in SQL Server

Aslo Rick Vander Ark created his own function, but I have not tested it. You can read more about this article: JSON Data Sharing Function

+5
source

You can use JSON Select , which has several functions to extract different types of data from JSON. For your requirements, you can do something like this:

 select dbo.JsonDecimal(my_column, 'latitude') as latitude, dbo.JsonDecimal(my_column, 'longitude') as longitude from my_table 

DISCLOSURE: I am the author of JSON Select, and so you are interested in using it :)

0
source

Source: https://habr.com/ru/post/1484376/


All Articles