相关疑难解决方法(0)

为什么我用这段代码得到JsonReaderException?

我有这个代码试图打开一个.json文件并阅读它:

[Route("{unit}/{begindate}")]
public string Get(string unit, string begindate)
{
    string _unit = unit;
    string _begindate = String.Format("{0}01", PlatypusWebReportsConstsAndUtils.HyphenizeYYYYMM(begindate));           
    string appDataFolder = HttpContext.Current.Server.MapPath("~/App_Data/");
    // semi-hardcoded file name for now
    string jsonFilename = string.Format("PoisonToe_{0}_{1}.json", _unit, _begindate);
    string fullPath = Path.Combine(appDataFolder, jsonFilename);
    JObject platypusComplianceJson = JObject.Parse(File.ReadAllText(fullPath));
    . . .
Run Code Online (Sandbox Code Playgroud)

在最后一行,我得到:

Newtonsoft.Json.JsonReaderException未被用户代码处理HResult = -2146233088 Message =从JsonReader读取JObject时出错.当前的JsonReader项不是对象:

根据我在这里读到的内容,我认为这是实现它的方法.我究竟做错了什么?

c# json.net

6
推荐指数
1
解决办法
7863
查看次数

标签 统计

c# ×1

json.net ×1