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

  • Home
  • SEARCH
  • 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 7503079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:05:52+00:00 2026-05-29T21:05:52+00:00

I get the InvalidOperationException when I try to deserialize a json string for my

  • 0

I get the InvalidOperationException when I try to deserialize a json string for my person object. It states that my Person object is not supported for deserialization

  [DataContract]
  public class Person
  {
    public string FirstName {get;set;}
    public string LastName {get; set;}
    public int Id {get; set;}
  }

An example of the json string

[{"name":"FirstName","value":"John"},{"name":"LastName","value":"Doe"},{"name":"Id","value":"1001"}]

And here’s where I get my exception

  Person p = new JavaScriptSerializer().Deserialize<Person>(json);

I’ve tried the DataContractJsonSerializer too without much luck.

  • 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-05-29T21:05:53+00:00Added an answer on May 29, 2026 at 9:05 pm

    I have tested your code and found the problem.

    Your jSon string provided a array of Person. Change to Person[] and it will work.

    Here is my test code

    string json = "[{\"name\":\"FirstName\",\"value\":\"John\"},{\"name\":\"LastName\",\"value\":\"Doe\"},{\"name\":\"Id\",\"value\":\"1001\"}]";
    Person[] p = new JavaScriptSerializer().Deserialize<Person[]>(json);
    

    Update

    Your jSon string is not in the right format. The Deserializer cant find the property to assign your values.

    The right would be.

    { "NameOfProperty" : "ValueOfProperty" }
    

    This is a right format

    [{"FirstName":"Jon", "LastName":"Doe"}, {"FirstName":"Jon", "LastName":"Doe"}]
    

    Test Code

    string json = "[{\"FirstName\":\"Jon\", \"LastName\":\"Doe\"}, {\"FirstName\":\"Jon\", \"LastName\":\"Doe\"}]";
    Person[] p = new JavaScriptSerializer().Deserialize<Person[]>(json);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We get the following error; The request was aborted: Could not create SSL/TLS secure
I try to read an XML file that contains the following element: <ho:CODED-TYPE ho:BASE-DATA-TYPE=A_UINT16
I'm using XmlSerializer to serialize an object that contains a generic list List <ChildBase>
When I try to play the sound file Windows Critical Stop.wav I get the
trying to get to grips with the code of a system that has been
I have two classes: namespace Something { [Serializable] public class Spec { public string
Whenever I try to debug my Windows Phone 7 C# app, I get the
I try to save an edited Entity Framework entity ApplyPropertyChanges, and get an exception:
I have the following problem: public Boolean Exists(String userName) { IRepository<User> = new UserRepository();
Help. I get the exception below when I try to run my service. I

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.