text: /**
  *Convert JSON collections to a rowset
  **/
  
  
  DECLARE @json NVARCHAR(MAX);
  SET @json = N'[
    {"id": 2, "info": {"name": "John", "surname": "Smith"}, "age": 25},
    {"id": 5, "info": {"name": "Jane", "surname": "Smith"}, "dob": "2005-11-04T12:00:00"}
  ]';
  
  SELECT *
  FROM OPENJSON(@json)
    WITH (
      id INT 'strict $.id',
      firstName NVARCHAR(50) '$.info.name',
      lastName NVARCHAR(50) '$.info.surname',
      age INT,
      dateOfBirth DATETIME2 '$.dob'
    );
    
    
    /**
  *Convert SQL Server data to JSON or export JSON
  **/
  
  SELECT id, firstName AS "info.name", lastName AS "info.surname", age, dateOfBirth AS dob
  FROM People
  FOR JSON PATH;
  
  
   /**
  *Import JSON data into SQL Server tables
  **/
  
  DECLARE @jsonVariable NVARCHAR(MAX);
  
  SET @jsonVariable = N'[
    {
      "Order": {  
        "Number":"SO43659",  
        "Date":"2011-05-31T00:00:00"  
      },  
      "AccountNumber":"AW29825",  
      "Item": {  
        "Price":2024.9940,  
        "Quantity":1  
      }  
    },  
    {  
      "Order": {  
        "Number":"SO43661",  
        "Date":"2011-06-01T00:00:00"  
      },  
      "AccountNumber":"AW73565",  
      "Item": {  
        "Price":2024.9940,  
        "Quantity":3  
      }  
    }
  ]';
  
  -- INSERT INTO <sampleTable>  
  SELECT SalesOrderJsonData.*
  FROM OPENJSON (@jsonVariable, N'$')
    WITH (
      Number VARCHAR(200) N'$.Order.Number',
      Date DATETIME N'$.Order.Date',
      Customer VARCHAR(200) N'$.AccountNumber',
      Quantity INT N'$.Item.Quantity'
    ) AS SalesOrderJsonData;
  