zoukankan      html  css  js  c++  java
  • Json-->Newton.Json.dll的使用方法

    Newton.Json.dll  for .NET2.0

    实体1

    public class Student
        {
            public string ID { get; set; }
            public string Name { get; set; }
            public int Age { get; set; }
        }

    实体2

    public class Classroom
        {
            public string ID { get; set; }
            public string CName { get; set; }
            public List<Student> stds { get; set; }
        }

    初始化

     Student st1 = new Student
                {
                    ID = "11",
                    Name = "cw",
                    Age = 1
                };
                Student st2 = new Student
                {
                    ID = "12",
                    Name = "wjb",
                    Age = 2
                };
                List<Student> std = new List<Student>();
                std.Add(st1);
                std.Add(st2);
                Classroom cls1 = new Classroom
                {
                    ID = "23",
                    CName = "1班",
                    stds = std
                };

     string xx= JsonConvert.SerializeObject(cls1);

    返回结果:

    {"ID":"23","CName":"1班","stds":[{"ID":"11","Name":"cw","Age":1},{"ID":"12","Name":"wjb","Age":2}]}

  • 相关阅读:
    Spark概念介绍
    KVM web管理工具——WebVirtMgr(一)
    Spark集群搭建
    阿里云DTS VS MySQLdump
    MySQL性能分析和优化-part 1
    为什么logstash进程的CPU使用率100%?
    技本功丨互联网+工业视觉异常检测分析
    Spark集群管理器介绍
    某云下系统上云方案及成本计算
    企业混合云架构设计
  • 原文地址:https://www.cnblogs.com/cwgyn/p/JSON.html
Copyright © 2011-2022 走看看