[XmlElement("space_id", IsNullable = true)]
[JsonPropertyAttribute("space_id")]
 public int? SpaceId;

解决方案 »

  1.   

    是这样滴!//下面这个特性是说当当前属性被序列化的时候,他的属性应该被重命名为"space_id",
    //而且即使当前属性为空的话,仍然序列化当前节点(默认如果属性为空,序列化结果中不出现当前节点)
    [XmlElement("space_id", IsNullable = true)]
    //在进行json序列化的时候,当前属性重命名为"space"
    [JsonPropertyAttribute("space_id")]
    //该值可以为空
     public int? SpaceId;
      

  2.   

    [XmlElement("space_id", IsNullable = true)]
    System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] 
    没有值当然不包含,赋值后且不为null才会有
    [JsonPropertyAttribute("space_id")]JsonPropertyAttribute:域和属性修饰标签,用于控制它们如何被序列化为一个json对象中
     public int? SpaceId;设置空类型nullable