Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:46:42+00:00 2026-06-12T15:46:42+00:00

I am unable to deserialize my custom object. public class UserInfo { public int

  • 0

I am unable to deserialize my custom object.

public class UserInfo
{
  public int Id1 { get; set; }
  public string Code { get; set; }
  public int Id2 { get; set; }
  public List<string> Roles { get; set; }
  public string Eg1 { get; set; }
  public DateTime Time{ get; set; }
  public string Eg2 { get; set; }
  public string Version { get; set; }
}

JavaScriptSerializer serializer = new JavaScriptSerializer();

return serializer.Deserialize<UserInfo>(raw);

The Deserialize is throwing an exception

“Cannot convert object of type ‘System.String’ to type ‘UserInfo'”

JSON Contents:

"\"{\\\"Id1\\\":0,\\\"Code\\\":null,\\\"Id2\\\":0,\\\"Roles\\\":null,\\\"Eg1\\\":\\\"Eg2\\\",\\\"Time\\\":\\\"\\\\/Date(-62135596800000)\\\\/\\\",\\\"Version\\\":\\\"1.0.0.0\\\"}\""

Note: Let me know, if it is unclear. I’ll edit the question.

— edited. ID2 changed to Id2. The real class is different in terms of variable names. Hence the issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:46:43+00:00Added an answer on June 12, 2026 at 3:46 pm

    You are passing a Javascript string to your deserializer because you have your object within an escaped string.

    After unescaping it, this is what the serializer receives:

    "{\"Id1\":0,\"Code\":null,\"Id2\":0,\"Roles\":null,\"Eg1\":\"Eg2\",\"Time\":\"\\/Date(-62135596800000)\\/\",\"Version\":\"1.0.0.0\"}"

    What you really want to send it is:

    {"Id1":0,"Code":null,"Id2":0,"Roles":null,"Eg1":"Eg2","Time":"\/Date(-62135596800000)\/","Version":"1.0.0.0"}"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Unable to cast object type System.Collections.Generic.List 1[NorthwindMVC3.Models.Product] to the type ofSystem.Collections.Generic.IEnumerator 1[NorthwindMVC3.Models.Product].\ public IEnumerator<Product>
I'm trying to build an object that looks something like this: public class MyObject
I'm getting an Unable to obtain public key for StrongNameKeyPair. exception using Newtonsoft's JsonConvert.SerializeObject
Attempting to deserialize a stream to List<T> (or any other type) and am failing
Unable to create instance of class TestClass. Error: System.UnauthorizedAccessException: Access to the path 'C:\Documents
I'm serializing some data like fields and custom class to create a binary data
I want to transfer a list object via Google Gson, but I don't know
We have a Sharepoint site which uses search. We get the following error: Unable
I have been trying to Deserialize an XmlResponse using RestSharp, but have been unable
Alright, I have a class EIR which is a List based from its base

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.