C#JObject.Parse错误

时间:2018-04-19 14:39:50

标签: json json.net

我收到以下异常:

Newtonsoft.Json.JsonReaderException in Newtonsoft.Json.dll ("Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1."). Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll ("Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1.

以下是代码:

JObject data = JObject.Parse(verigetir(veri.getir(), "cari_ip_alma.php"));

public string verigetir(string veri, string sayfa)
{
    string postData;

    WebRequest request = WebRequest.Create(server + sayfa);
    request.Method = "POST";
    postData = veri;
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = byteArray.Length;
    Stream dataStream = request.GetRequestStream();
    dataStream.Write(byteArray, 0, byteArray.Length);
    dataStream.Close();
    WebResponse response = request.GetResponse();
    dataStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(dataStream);

    return reader.ReadToEnd();

    reader.Close();
    dataStream.Close();
    response.Close();
}

class parametreOlustur
{
    public string data;

    public void birlestir(string a, string b)
    {
        data += "&" + a + "=" + b;
    }

    public string getir()
    {
        return data;
    }
}

PHP代码:

https://shrib.com/?v=md#iT73qB_Lr250Uoh8CZbk

如果我将PHP代码$ row = $ sql-> fetchAll(PDO :: FETCH_ASSOC)fetchAll更改为Fetch,程序正在运行但获取第一个数据。

0 个答案:

没有答案