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 5983139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:11:15+00:00 2026-05-22T22:11:15+00:00

I am serializing and deserializing a Dictionary in C#. My data structure is: public

  • 0

I am serializing and deserializing a Dictionary in C#. My data structure is:

    public class DataField
{
    private string _Name;
    public string Name
    {
        get { return _Name; }
        set
        {
            _Name = value;
        }
    }

    private string _Label;
    public string Label
    {
        get { return _Label; }
        set
        {
            _Label = value;
        }
    }

    private ControlType _TypeOfControl;
    public ControlType TypeOfControl
    {
        get { return _TypeOfControl; }
        set { _TypeOfControl = value; }
    }

    private int _Width;
    public int Width
    {
        get { return _Width; }
        set
        {
            _Width = value;
        }
    }
    private DataType _DataType;
    public DataType DataType
    {
        get { return _DataType; }
        set { _DataType = value; }
    }

    private Control _ControlAccessor;
    public Control ControlAccessor
    {
        get { return _ControlAccessor; }
        set { _ControlAccessor = value; }
    }


    private Type _ControlType;
    public Type ControlType
    {
        get { return _ControlType; }
        set { _ControlType = value; }
    }

    private List<KeyValuePair<string, string>> _Items;
    public List<KeyValuePair<string, string>> Items
    {
        get { if (_Items == null) _Items = new List<KeyValuePair<string, string>>(); return _Items; }
        set { _Items = value; }
    }

The object I am serializing is Dictionary<string, DataField>(). I am doing:

JavaScriptSerializer js = new JavaScriptSerializer();
string str = js.Serialize(ht);`

The string I get is correct:

{"Title" {"Name":"Title","Label":null,"TypeOfControl":0,"Width":200,"DataType":0,"ControlAccessor":null,"ControlType":null,"Items":[]}
,"Price":{"Name":"Price","Label":null,"TypeOfControl":0,"Width":100,"DataType":1,"ControlAccessor":null,"ControlType":null,"Items":[]}
,"Category":{"Name":"Category","Label":null,"TypeOfControl":0,"Width":100,"DataType":1,"ControlAccessor":null,"ControlType":null,"Items":[]}
,"Test":{"Name":"Test","Label":null,"TypeOfControl":0,"Width":100,"DataType":1,"ControlAccessor":null,"ControlType":null,"Items":[]}
,radioGeo":{"Name":"radioGeo","Label":null,"TypeOfControl":3,"Width":0,"DataType":0,"ControlAccessor":null,"ControlType":null
,"Items":[{"Key":"Position","Value":"posit"},{"Key":"Area","Value":"area"},{"Key":"Area","Value":"area"}]}
,"htmled":{"Name":"htmled","Label":null,"TypeOfControl":2,"Width":170,"DataType":0,"ControlAccessor":null,"ControlType":null,"Items":[]}}";

When I deserialize it, ALMOST everything is correct. The problem is the nested lists. While they serialize fine, the list is empty when I put it back to together.

Any suggestions?

  • 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-22T22:11:16+00:00Added an answer on May 22, 2026 at 10:11 pm

    I assume you are using Json.net
    I encouter the same problem at work, the deserialization of the lists was incomplete. This bug has been added to the issue tracker of the project. The workaround we found is to not put the list as the last var in an object.

    Hope this can help you while waiting for a patch.

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

Sidebar

Related Questions

I'm serializing class which contains DateTime property. public DateTime? Delivered { get; set; }
I am serializing some C structure to string and than deserializing it with strtok()
Should one create unit tests involving IO? Ie, testing a class method for serializing/deserializing
I'm de/serializing an object like so: public class myClass : ISerializable { public List<OType>
I'm trying to create a class that will contain functions for serializing/deserializing objects to/from
I have an existing class for serializing and deserializing objects to/from XML. It's a
I'm working with asmx webservices and serializing/deserializing a lot of data through them for
I am serializing and deserializing following domain object to JSON using Jackson 1.8.3 public
I'm writing classes which (de)serialize to/from XML. When serializing and deserializing, the class gets
I have a HashMap that I am serializing and deserializing to an Oracle db,

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.