I am currently having this kind of stored procedure where I have nested select statements to get a nested JSON output.
ALTER PROCEDURE [schema].[getJSON] AS S