api - Newtonsoft.Json 在 RestEase 中抛出异常
问题描述
我遇到了这样的例外
JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 1, position 1.
我正在使用带有此类界面的RestEase( https://github.com/canton7/RestEase )
public interface ISomeApi
{
[Get("{version}/data/count")]
Task<SomeResult> GetCount(
[Path] string version,
[Query("metaType")] string metaType,
[Query("query", QuerySerializationMethod.Serialized)] QueryParams queryParams);
}
我的查询参数模型
public class QueryParams
{
[JsonProperty("foo")]
public string Foo { get; set; }
[JsonProperty("bar")]
public string Bar{ get; set; }
[JsonProperty("bass")]
public string Bass{ get; set; }
[JsonProperty("boom")]
public string Boom{ get; set; }
}
为什么我会得到这个异常?做错了什么?
我试图避免使用QueryParams
并且只是string
在我传递的地方使用了已经转换为字符串表示的 json 模型,但得到了相同的异常。我也尝试转义 json 特定符号,但没有帮助。
解决方案
推荐阅读
- python - 如何计算句子中单词手套嵌入的平均值
- javascript - Xero-Node 未定义的回调参数
- sql - 如何计算 SQL 中 1 个字段中每个条件的 SUM?
- android - 使用包含 300 多个类的文件反序列化 Json
- spring-boot - 目标不可达,标识符 [tinyCalculator] 解析为 null
- python - 如何阻止 Pandas 从 csv 文件中删除封闭字符?
- javascript - 如何更改数组内对象的属性值
- colors - AppleScript 颜色检测
- arrays - 在 PostgreSQL 中对 bigint[] 列进行排序
- php - Symfony 5 NormalizerInterface 未找到