我在 json.net 中编写了一个自定义 JSON 转换器类,但无法弄清楚为什么在反序列化时会出现以下异常。
填充对象时出现意外的初始标记“EndObject”。预期的 JSON 对象或数组。路径 '',第 1 行,位置 177。
我的项目中有其他转换器,它们的模型非常相似,它们可以正常工作,所以我不确定为什么会出现这样的问题。
这是被序列化的对象:
[JsonConverter(typeof(CreateCRMIntegrationPromptJsonConverter))]
public abstract class CreateCRMIntegrationDirectPromptBaseBindingModel
{
public bool IncludeInOutput { get; set; }
public string Label { get; set; }
public string Value { get; set; }
public IValidateCRMField Validator { get; set; }
public string ValidatorType { get; set; }
public CRMIntegrationDirectPromptType Type { get; set; }
}
public class CreateCRMIntegrationPromptMobilePhoneBindingModel : CreateCRMIntegrationDirectPromptBaseBindingModel
{
public bool FormatPhoneNumber { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和转换器
public class …Run Code Online (Sandbox Code Playgroud)