I want to display the below query output into JSON Format(Required output format)
select ApplicationID ApplicationID ,Roleid Roles from UserRoles where userid=1
If you are using SQL Server 2016+, you can use FOR JSON statement
FOR JSON
SELECT ApplicationID ApplicationID, Roleid Roles FROM UserRoles WHERE userid = 11 AND applicationid IS NOT NULL FOR JSON AUTO
Take a look into this: Format Query Results as JSON with FOR JSON