Ajaz Khan

Ajaz Khan

  • 1.1k
  • 690
  • 40.2k

Return JSON object (ASP.NET WebAPI)

Apr 1 2022 9:23 AM

I have ASP.NET Web API

Its returning JSON like this

{
    "Status": "success",
    "StatusCode": 605,
    "Data": [
        {
            "SiteGuid": "cb36a2f2-0793-46d5-a9f4-03531310bcd2122",
            "Site": "**",
            "flagSet": 0
        },
        {
            "SiteGuid": "c358229e-3ed3-446e-890d-fffa67008642123",
            "Site": "**",
            "flagSet": 0
        },
        {
            "SiteGuid": "426a3694-0703-4094-840e-eab8afe402c4123",
            "Site": "**",
            "flagSet": 0
        }
    ]
}

But I need to return JSOn Object instead of it

[{
   "id": "",
   "contactListId": "***************",
   "data": {"Service Line": "8888",
        "Problem Type Code": "123",
        "Problem Type Desc": "Water problem",
        "Request Priority": "1",
        "Supplier": "XYZ",
        "Site": "***",
        "Unit#": "1001",
        "Request Creation Date":"25/02/2022",
        "Request Closure Date": "03/03/2022",
        "Mobile (MSISDN)":"+****",
        "EXT#": "2002",
        "Customer's Name": "***",
        "Customer's eMail": "*****",
        "TimeZone":"****"
    },
   "callable": true,
   "phoneNumberStatus": {}
},

{
   "id": "",
   "contactListId": "***************",
   "data": {"Service Line": "8888",
        "Problem Type Code": "123",
        "Problem Type Desc": "Water problem",
        "Request Priority": "1",
        "Supplier": "XYZ",
        "Site": "***",
        "Unit#": "1001",
        "Request Creation Date":"25/02/2022",
        "Request Closure Date": "03/03/2022",
        "Mobile (MSISDN)":"+****",
        "EXT#": "2002",
        "Customer's Name": "***",
        "Customer's eMail": "*****",
        "TimeZone":"****"
    },
   "callable": true,
   "phoneNumberStatus": {}
}]

 

How I need to modify my controller?

TIA

 


Answers (3)