我正在实现JsonConverter。我想知道当前WriteJson方法的属性名称是什么。
public class MyJsonConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
string name = ??? // How can I get the property name under serialization here?
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
// Same question....
}
}
找到:可以从解析
string name = writer.Path;
和
string name = reader.Path;