json - 当我使用字符串时出现 Newtonsoft.Json.JsonReaderException
问题描述
Newtonsoft.Json.JsonReaderException:“解析值后遇到意外字符:
c#4.5 中的 Newtonsoft.Json version="11.0.2"
JsonConvert.DeserializeObject<QueryModel>(Json);
private class QueryModel
{
public Pagination pagination { get; set; }
public string queryJson { get; set; }
}
public class Pagination
{
public int rows { get; set; }
public int page { get; set; }
}
当我使用 json
"{"pagination":{"rows":10,"page":1},"queryJson":"{}"}" 就可以了
但使用
"{"pagination":{"rows":10,"page":1},"queryJson":\"{/\"keyword/\":/\"test/\"}\"}" 是错误的
解决方案
Sub JsonStr 使用 '' 替换 \"\" 像 "{"pagination":{"rows":10,"page":1},"queryJson":\"{'keyword':'test'}\"}"
推荐阅读
- javascript - 如何更改 HTML5 画布画板的高度?
- android - 无法更改 recyclerview 中特定项目的背景颜色
- maven - org.osgi.framework.BundleException:不支持的“Bundle-ManifestVersion”值:1
- java - 在布局文件的 Imageview 中获取空指针异常
- node.js - 如何通过 req.body 将对象数组发送到节点/猫鼬
- c - 由于排序功能导致的分段错误
- python-3.x - Python3:连接到 Windows 时 paramiko_expect 的 SSHClientInteraction 输出不正确
- php - 如何在 PHP 中清理搜索栏字符串
- c# - c#如何用多个字符替换一个字符
- javascript - Knex 插入多条记录只返回插入的第一条记录