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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:13:07+00:00 2026-05-12T15:13:07+00:00

I have some types that I want to serialize/deserialize and generate a UI based

  • 0

I have some types that I want to serialize/deserialize and generate a UI based on the selected object. The UI will also change the object which in turn I will have to serialize to store it in my app.

So:

[obj_apple stored in the app] -> select obj_apple -> deserialize -> show in UI -> use the UI to change obj_apple -> deselect obj_apple -> serialize -> [obj_apple stored in the app]

The objects have to be serialized/deserialized and this data has to be string. That’s why I thought having an xml serializer would be better.

Which type of serializer would be the best? And are there any good examples to implement this for custom types?

  • 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-12T15:13:07+00:00Added an answer on May 12, 2026 at 3:13 pm

    You have a few choices for strings; xml, which can be done simply with XmlSerializer (or DataContractSerializer, but that offers much less control over the xml) or JSON (JSON.net, etc).

    Typical classes for XmlSerializer would look simply like:

    public class Apple {
        public string Variety {get;set;}
        public decimal Weight {get;set;}
        // etc
    }
    

    (note I would expect the above to work the JSON.net too)

    The above class should also work fine in data-binding scenarios etc, thanks to the properties.

    You would serialize this:

        Apple obj = new Apple { Variety = "Cox", Weight = 12.1M};
        XmlSerializer ser = new XmlSerializer(typeof(Apple));
    
        StringWriter sw = new StringWriter();
        ser.Serialize(sw, obj);
        string xml = sw.ToString();
    
        StringReader sr = new StringReader(xml);
        Apple obj2 = (Apple)ser.Deserialize(sr);
    

    but you can customize the xml:

    [XmlType("apple"), XmlRoot("apple")]
    public class Apple {
        [XmlAttribute("variety")]
        public string Variety {get;set;}
        [XmlAttribute("weight")]
        public decimal Weight {get;set;}
        // etc
    }
    

    DataContractSerializer is ideally more like:

    [DataContract]
    public class Apple {
        [DataMember]
        public string Variety {get;set;}
        [DataMember]
        public decimal Weight {get;set;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some tables that represent various types. They usually just consist of an
I have some logic, which defines and uses some user-defined types, like these: class
I have got some code to load an assembly and get all types, which
I have some JS code which generates the following object, return { type: some
I have about 10million values that I need to put in some type of
I have some generic types, like the following: public struct Tuple<T1, T2> { ...
I have a small namespace containing some type definitions, which I use to make
I have a family of classes that contain only variables of the following types:
I'mm using boost to serialize and deserialize some classes Like so: boost::archive::xml_oarchive xmlArchive(oStringStream); xmlArchive.register_type(static_cast<BaseMessage
When I have some function of type like f :: (Ord a) => a

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.