You must Sign In to post a response.
  • Category: ASP.NET

    Error while deserilizing json in C#

    I am getting response in json like this .
    data={"Id": "234", "Name": "pinky", "MobileNumber": "", "ClassName": "Class1_Physics", "DOBTime": "1990-04-11 15:46:38", "Landline": "", "Status": "Unmarried"}.

    I want to deserilize json and insert into table. I have created 2 classes for it and using dll of Newtonsoft for deserilization.

    public class JsonResult
    {
    public string Id { get; set; }
    public string Name { get; set; }
    public string MobileNumber { get; set; }
    public string ClassName { get; set; }
    public string DOBTime { get; set; }
    public string Landline { get; set; }
    public string Status { get; set; }
    }

    public class JsonResultRoot
    {
    [JsonProperty(PropertyName = "data")]
    public string Data { get; set; }

    public JsonResult JsonResult
    {
    get { return JsonConvert.DeserializeObject<JsonResult>(Data); }
    }
    }

    Code :
    decodedUrl : store actual json data/string var JsonData = JsonConvert.DeserializeObject(decodedUrl).JsonResult;
  • #769185
    Hi Pinky,

    Could you please post the error which you are getting while deserializing the json ? It would be better to respond us for the exact problem.

    Thanks,
    Bharati


  • Sign In to post your comments