0

这是我在浏览器中收到的来自服务器的回复

{

"code": 200,
"message": "\u0634\u0645\u0627 \u0647\u06cc\u0686 \u06a9\u0627\u0631\u0628\u0631\u06cc \u062a\u0627 \u06a9\u0646\u0648\u0646 \u062b\u0628\u062a \u0646\u06a9\u0631\u062f\u0647 \u0627\u06cc\u062f.",
"data": [{
    "id": "33",
    "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
    "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
    "u_token": "JNSDTm8ugf",
    "user_type": "\u0639\u0627\u062f\u06cc",
    "phone_number": "09383133623",
    "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f6 - \u06f0\u06f2:\u06f3\u06f0:\u06f2\u06f0",
    "is_active": "\u0641\u0639\u0627\u0644",
    "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
    "user_charge": "0",
    "bank_card": "6037997343520046",
    "add_sub_amount": "0",
    "supporter_name": "Admin"
}, {
    "id": "34",
    "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
    "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
    "u_token": "JNSDTm8ugf",
    "user_type": "\u0639\u0627\u062f\u06cc",
    "phone_number": "09383133623",
    "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
    "is_active": "\u0641\u0639\u0627\u0644",
    "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
    "user_charge": "0",
    "bank_card": "6037997343520046",
    "add_sub_amount": "0",
    "supporter_name": "Admin"
}, {
    "id": "35",
    "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
    "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
    "u_token": "JNSDTm8ugf",
    "user_type": "\u0639\u0627\u062f\u06cc",
    "phone_number": "09383133623",
    "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
    "is_active": "\u0641\u0639\u0627\u0644",
    "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
    "user_charge": "0",
    "bank_card": "6037997343520046",
    "add_sub_amount": "0",
    "supporter_name": "Admin"
}, {
    "id": "36",
    "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
    "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
    "u_token": "JNSDTm8ugf",
    "user_type": "\u0639\u0627\u062f\u06cc",
    "phone_number": "09383133623",
    "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
    "is_active": "\u0641\u0639\u0627\u0644",
    "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
    "user_charge": "0",
    "bank_card": "6037997343520046",
    "add_sub_amount": "0",
    "supporter_name": "Admin"
}, {
    "id": "37",
    "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
    "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
    "u_token": "JNSDTm8ugf",
    "user_type": "\u0639\u0627\u062f\u06cc",
    "phone_number": "09383133623",
    "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
    "is_active": "\u0641\u0639\u0627\u0644",
    "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
    "user_charge": "0",
    "bank_card": "6037997343520046",
    "add_sub_amount": "0",
    "supporter_name": "Admin"
}, {
    "id": "38",
    "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
    "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
    "u_token": "JNSDTm8ugf",
    "user_type": "\u0639\u0627\u062f\u06cc",
    "phone_number": "09383133623",
    "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
    "is_active": "\u0641\u0639\u0627\u0644",
    "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
    "user_charge": "0",
    "bank_card": "6037997343520046",
    "add_sub_amount": "0",
    "supporter_name": "Admin"
}, {
    "id": "39",
    "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
    "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
    "u_token": "JNSDTm8ugf",
    "user_type": "\u0639\u0627\u062f\u06cc",
    "phone_number": "09383133623",
    "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
    "is_active": "\u0641\u0639\u0627\u0644",
    "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
    "user_charge": "0",
    "bank_card": "6037997343520046",
    "add_sub_amount": "0",
    "supporter_name": "Admin"
}]

}

这是我尝试使用 HttpClient Lib 从 C# 获取数据时的回应

{

"code": 200,
"message": "\u0634\u0645\u0627 \u0647\u06cc\u0686 \u06a9\u0627\u0631\u0628\u0631\u06cc \u062a\u0627 \u06a9\u0646\u0648\u0646 \u062b\u0628\u062a \u0646\u06a9\u0631\u062f\u0647 \u0627\u06cc\u062f.",
"data": [{
            "id": "33",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
            "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
            "u_token": "JNSDTm8ugf",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09383133623",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f6 - \u06f0\u06f2:\u06f3\u06f0:\u06f2\u06f0",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
            "user_charge": "0",
            "bank_card": "6037997343520046",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "34",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
            "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
            "u_token": "JNSDTm8ugf",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09383133623",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
            "user_charge": "0",
            "bank_card": "6037997343520046",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "35",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
            "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
            "u_token": "JNSDTm8ugf",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09383133623",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
            "user_charge": "0",
            "bank_card": "6037997343520046",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "36",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
            "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
            "u_token": "JNSDTm8ugf",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09383133623",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
            "user_charge": "0",
            "bank_card": "6037997343520046",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "37",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
            "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
            "u_token": "JNSDTm8ugf",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09383133623",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
            "user_charge": "0",
            "bank_card": "6037997343520046",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "38",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
            "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
            "u_token": "JNSDTm8ugf",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09383133623",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
            "user_charge": "0",
            "bank_card": "6037997343520046",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "39",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
            "lname": " \u062c\u0639\u0641\u0631\u067e\u0648\u0631 \u0632\u0646\u0648\u0632\u06cc",
            "u_token": "JNSDTm8ugf",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09383133623",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f0:\u06f2\u06f0",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834220.JPG",
            "user_charge": "0",
            "bank_card": "6037997343520046",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "42",
            "fname": "\u0634\u0631\u06a9\u062a \u0627\u0635\u0644\u0627\u062d \u062a\u0648\u0627\u0646",
            "lname": "\u0634\u0631\u06a9\u062a \u0627\u0635\u0644\u0627\u062d \u062a\u0648\u0627\u0646 \u0627\u06cc\u0633\u062a\u0627\u06cc \u063a\u0631\u0628",
            "u_token": "JNAESNwm2S",
            "user_type": "\u0639\u0627\u062f\u06cc",
            "phone_number": "09183896082",
            "created_date": "\u06f1\u06f3\u06f9\u06f9\/\u06f0\u06f4\/\u06f2\u06f5 - \u06f2\u06f2:\u06f0\u06f9:\u06f2\u06f8",
            "is_active": "\u0641\u0639\u0627\u0644",
            "profile_img": "http:\/\/sanypay.org\/v1\/images\/1594834768.jpg",
            "user_charge": "0",
            "bank_card": "5041721060355956",
            "add_sub_amount": "0",
            "supporter_name": "Admin"
        }, {
            "id": "43",
            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",





            "lname": " \u062c\u06HTTP/1.1 200 OK
            Connection: Keep - Alive
            Content - Type: text / html;charset = UTF - 8
            Content - Length: 5427
            Date: Wed,
            15 Jul 2020 17: 40: 36 GMT
            Server: LiteSpeed

            {
                "code": 200,
                "message": "\u0634\u0645\u0627 \u0647\u06cc\u0686 \u06a9\u0627\u0631\u0628\u0631\u06cc \u062a\u0627 \u06a9\u0646\u0648\u0646 \u062b\u0628\u062a \u0646\u06a9\u0631\u062f\u0647 \u0627\u06cc\u062f.",
                "data": [{
                            "id": "33",
                            "fname": "\u0645\u06cc\u0631 \u0627\u0628\u0631\u0627\u0647\u06cc\u0645",
                            "lname": "

如您所见,它也不是有效的 JSON。我找到了为什么会发生这种情况,但我无法修复它,因为我从服务器获取大量数据。无论有多少记录,当我从浏览器获取数据时都可以,但是当我尝试从我的代码中获取时,它给了我这样无效的 JSON带有服务器详细信息,例如 lite 速度或内容长度等。

这是我的代码:

  var values = new Dictionary<string, string>
             {
                 { "admin_id", Constants.userID }
             };
        var stringPayload = JsonConvert.SerializeObject(values);
        var content = new StringContent(stringPayload, Encoding.UTF8, "application/json");
        HttpResponseMessage response = await client.PostAsync(AppUrls.getAcceptors(), content);
        var responseString = await response.Content.ReadAsStringAsync();

       // MessageBox.Show(responseString);
        Console.WriteLine(responseString);
        try {
            UserParserRoot respon = JsonConvert.DeserializeObject<UserParserRoot>(responseString);
            if (respon.code == 200)
            {
                userList = respon.data;
                allItems = new ListViewItem[respon.data.Count];

                for (int i = 0; i < allItems.Count(); i++)
                {

                    allItems[i] =
                   new ListViewItem(new string[] {
                        (i+1)+"",respon.data[i].fname,respon.data[i].lname,respon.data[i].u_token,
                        respon.data[i].user_type,respon.data[i].phone_number,respon.data[i].created_date,
                        respon.data[i].is_active,respon.data[i].user_charge+" تومان ",
                    respon.data[i].add_sub_amount,respon.data[i].supporter_name
                       });
                }
                AccountManagementList.Items.AddRange(allItems);
                AccountManagementProgress.Visible = false;
            }
            else 
            {
                AccountManagementProgress.Visible = false;
                MessageBox.Show(respon.message+"");
            }
        } catch (Exception ex) {
            
            MessageBox.Show(ex.Message.ToString());
        }
4

0 回答 0