首页 > 解决方案 > 当我使用字符串时出现 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/\"}\"}" 是错误的

标签: json

解决方案


Sub JsonStr 使用 '' 替换 \"\" 像 "{"pagination":{"rows":10,"page":1},"queryJson":\"{'keyword':'test'}\"}"


推荐阅读