Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如果在JSON文件C中添加了内容,则添加文本部分_C#_Json - Fatal编程技术网

C# 如果在JSON文件C中添加了内容,则添加文本部分

C# 如果在JSON文件C中添加了内容,则添加文本部分,c#,json,C#,Json,我基本上有一个程序,可以在网站上检查JSON文件。我希望能够在添加新对象时使用列表框添加对象,但我只知道如何单独添加每个对象 try { HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://mining.bitcoin.cz/accounts/profile/json/" + APIKey);

我基本上有一个程序,可以在网站上检查JSON文件。我希望能够在添加新对象时使用列表框添加对象,但我只知道如何单独添加每个对象

                try
            {

                HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://mining.bitcoin.cz/accounts/profile/json/" + APIKey);
                HttpWebResponse response = (HttpWebResponse)Request.GetResponse();
                Stream responseStream = response.GetResponseStream();
                StreamReader readStream = new StreamReader(responseStream, System.Text.Encoding.GetEncoding("utf-8"));
                String json = readStream.ReadToEnd();
                readStream.Close();
                var jo = JObject.Parse(json);
                uName.Text = ((string)jo["username"]);
                eRewards.Text = ((string)jo["estimated_reward"]);
                uRewards.Text = ((string)jo["unconfirmed_reward"]);
                cRewards.Text = ((string)jo["confirmed_reward"]);
                bRating.Text = ((string)jo["rating"]);
                bHashrate.Text = ((string)jo["hashrate"]);
                walletID.Text = ((string)jo["wallet"]);
            }
            catch (Exception)
            {

            }

        }
        else
        {
            MessageBox.Show("Input API Key", "Mining.BitCoin.Cz", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

你能给我们更多的信息吗?你的活动是什么?“单独添加”是什么意思?到目前为止,您做了什么?@cansik我将以与上面代码完全相同的方式输入其他JSON对象。我想知道是否有办法将它们添加到整个类别下,因为如果添加或删除了一个新的类别,程序将出错,或者如果出现了一个新的类别,则不会显示。建议将一次性HttpWebResponse、Stream和StreamReader包装在语句中。