からNULLを返すために、私はクラスを持っている:どのようJsonConvert.DeserializeObject
public class CustomResponse
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string Message {get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string Details {get; set; }
}
それから私は、このクラスにJSON文字列をデシリアライズしようとしています。たとえば
var settings = new JsonSerializerSettings
{
NullValueHandling.Ignore,
MissingMemberHandling.Ignore,
};
var customResponse = JsonConvert.Deserialize<CustomResponse>(jsonString, settings);
私のJSON文字列:
{"DocumentId":"123321", "DocumentNumber":"ABC123"}
結果として、すべてのプロパティがNULLであるオブジェクトがありますが、customResponse
はNULLではありません。どのように結果にNULLを取得するのですか?
のような多相コンバータを使用することを検討してください。[カスタム 'JsonConverter'](http://www.newtonsoft.com/json/help/html/CustomJsonConverter.htm )そのために。 – dbc
使用しているJSON文字列を追加できますか? – Zinov
なぜ 'customResponse'が' null'になると思いますか? –