Added code for getting json data in the right format irrespective of whether the id is present or not
Added code so that getting json format is same whether id is present or not