c# 对象转JSON当为null时忽略

学习之后,在这里记录一下

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

class EngineScoreSubWord
{
//[JsonProperty(NullValueHandling=NullValueHandling.Ignore)]
public string subtext { get; set; }
public float volume { get; set; }
public float begin { get; set; }
public float end { get; set; }
[JsonProperty(NullValueHandling=NullValueHandling.Ignore)]
public float? score { get; set; } //add by grq 
}

posted @ 2017-12-09 16:21  leyer  阅读(2960)  评论(0)    收藏  举报