Sandeep Kumar

Sandeep Kumar

  • 1k
  • 683
  • 59.5k

how assign json data to my model class

Jun 26 2023 5:17 AM

my json

{ "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==", } ] }

 

My Model Class

---------------

 

 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> UploadedImage { get; set; }
        }
        public class UploadedFile
        {
            public string UploadedFiles { get; set; }
        }

My Code To Receive Json Data 

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();        
            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 (1)