Microsoft SQL Server Get key:value pairs from JSON text


Example

OPENJSON function parse JSON text and returns all key:value pairs at the first level of JSON:

declare @json NVARCHAR(4000) = N'{"Name":"Joe","age":27,"skills":["C#","SQL"]}';
SELECT * FROM OPENJSON(@json);
keyvaluetype
NameJoe1
age272
skills["C#","SQL"]4

Column type describe the type of value, i.e. null(0), string(1), number(2), boolean(3), array(4), and object(5).