C # problems with JSON library and XML serialization and deserialization

Source: Internet
Author: User

JSON normally does not serialize or deserialize Private Members. Therefore, when using JSON for deep copy, data will be lost.

Solution: declare a public member. During JSON serialization and deserialization, if the class contains icommand members, serialization may fail. Therefore, only the model layer should be used for JSON applications in WPF. JSON declares a base class object. In fact, when the object of the derived class is serialized and deserialized, the string during serialization is correct, but deserialization is because the base class is declared, therefore, it is a base class object, resulting in data loss of the derived class object. Solution: XML serialization or deserialization may be better at this time. The problem with XML serialization deserialization is that the serialization of a dictionary object is not successful unless you implement the serialization interface for dictionay yourself. JSON may be used in this case. You can use [xmlignore] or [jsonignore] to control whether attribute serialization is ignored during XML and JSON serialization.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.