Sandeep Kumar

Sandeep Kumar

  • 1.1k
  • 684
  • 61.7k

how to receive this json sent by postman in a class

Jun 24 2023 4:12 AM

My Json is fixed no change in json format

{ "ID": 0, "StationId": 1, "UnitId": 1, "OutageTypeId": 1, "ZoneId": 2, "FinYear": "2018-2019", "PhotoTag": "azxxxcssac",

"UploadedFiles": [{

"UploadedFiles": "data:image/jpeg;base64,/9j/4AA/QSkZ***Jggg==",

"UploadedFiles": "data:image/jpeg;base64,/9j/4AA/QSkZ***Jggg==",

"UploadedFiles": "data:image/jpeg;base64,/9j/4AA/QSkZ***Jggg=="

}]

}

 

what should be my class to receive the json value

like

 public class ImageUploadModel
        {
            public int ID { get; set; }
            public int StationId { get; set; }
            public int UnitId { get; set; }
            public int OutageTypeId { get; set; }
            public int ZoneId { get; set; }
            public string FinYear { get; set; }
            public string PhotoTag { get; set; }
            public List<UploadedFile> UploadedFiles { get; set; }
        }
        public class UploadedFile
        {
            public string UploadedFiles { get; set; }
        }

i want to assign json data to my above class but how can i assign UploadedFiles array data to my my class  variable 

this way i m assigning the json value

   public List<object> Pms_INSERT_UPDATE_DATA_Using_Base(JObject jsonParam, int UserId)
        {
            DataTable DtPhoto = new DataTable();
            List<object> returnVal = new List<object>();
            DtPhoto.Columns.Add("PhotoTag", typeof(System.String));
            ImageUploadModel IM = new ImageUploadModel();
            //List<int> returnVal = new List<int>();
            IM.ID = (int)jsonParam["ID"];
            IM.StationId = (int)jsonParam["StationId"];
            IM.UnitId = (int)jsonParam["UnitId"];
            IM.OutageTypeId = (int)jsonParam["OutageTypeId"];
            IM.ZoneId = (int)jsonParam["ZoneId"];
            IM.FinYear = (string)jsonParam["FinYear"];
            IM.PhotoTag = (string)jsonParam["PhotoTag"];

IM.UploadedFiles =  ???------------Here is Issue 

 

 


Answers (4)