sql - Turning JSON into a Table -


{     "id":1,     "key1":"",     "arraykey1":[         {              "arraykey":""              "objectkey":{                  "obj":""              }         }     ] } 

above json object have stored in database , want use openjson create tabular format. know can whole openjson ( ) , manually create columns. wanted know if has idea of how recursively or programatically create table without having identity each key table. end having couple dozen fields. i'm not worried excluding of items. if wanted pull records back, begin new 2016 sql server?

here official documentation.

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 *   openjson(@json)    (id int 'strict $.id',          firstname nvarchar(50) '$.info.name', lastname nvarchar(50) '$.info.surname',          age int, dateofbirth datetime2 '$.dob') 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -