C # programming JSON instance code

Source: Internet
Author: User

The instance code is as follows:

  1. Using System;
  2. Using System. Collections. Generic;
  3. Using System. Text;
  4. Using Newtonsoft. Json;
  5. Namespace TestJson
  6. {
  7. Class Program
  8. {
  9. Static void Main (string [] args)
  10. {
  11. String json = "{" a ":" sadsad "," c ": {" d ":" adad "}}";
  12. // CCC ccc = new CCC ();
  13. // Ccc. d = "adad ";
  14. // AAA aaa = new AAA ();
  15. // Aaa. a = "sadsad ";
  16. // Aaa. B = "dfgdg ";
  17. // Aaa. c = ccc;
  18. AAA aaa = new AAA ();
  19. Aaa = JavaScriptConvert. DeserializeObject (json );
  20. // String json = JavaScriptConvert. SerializeObject (aaa );
  21. // Console. WriteLine (json );
  22. Console. Read ();
  23. }
  24. }
  25. Public class AAA {
  26. Private string m_a;
  27. Public string
  28. {
  29. Get {return m_a ;}
  30. Set {m_a = value ;}
  31. }
  32. Private string m_ B;
  33. Public string B
  34. {
  35. Get {return m_ B ;}
  36. Set {m_ B = value ;}
  37. }
  38. Private CCC m_c;
  39. Public CCC c
  40. {
  41. Get {return m_c ;}
  42. Set {m_c = value ;}
  43. }
  44. }
  45. Public class CCC
  46. {
  47. Private string m_d;
  48. Public string d
  49. {
  50. Get {return m_d ;}
  51. Set {m_d = value ;}
  52. }
  53. }
  54. }

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.