OPENJSON() optimization for poorly structured API response

Solution 1:

Like this:

select u.*
from openjson(@user_response, '$.results.users') d
cross apply 
openjson(d.value)
with
(
   id         int          '$.id',
   first_name varchar(200) '$.first_name',
   last_name  varchar(200) '$.last_name',
   username   varchar(200) '$.username',
   email      varchar(200) '$.email'
) u
 

if you need it you can get the object name with d.[key]