我已经花了两天时间对代码样本等进行"最好的"工作,尝试将一个非常大的JSON文件读入c#中的数组中,以便稍后将其拆分为二维数组进行处理.
我遇到的问题是我找不到任何人做我想做的事情的例子.这意味着我只是想编写一些希望最好的代码.
我已经成功地完成了一些工作:
这是通过下面的代码完成的,但是在输入几行到数组后它会崩溃程序.这可能与文件大小有关.
// If the file extension was a jave file the following
// load method will be use else it will move on to the
// next else if statement
if (fileExtension == ".json")
{
int count = 0;
int count2 = 0;
int inOrOut = 0;
int nRecords=1;
JsonTextReader reader = new JsonTextReader(new StreamReader(txtLoaction.Text));
string[] rawData = new string[5];
while (reader.Read())
{
if (reader.Value != null)
if (inOrOut == 1)
{
if …Run Code Online (Sandbox Code Playgroud) 我很难理解如何使用JSON.net来读取json文件.
该文件看起来像这样:
"version": {
"files": [
{
"url": "http://www.url.com/",
"name": "someName"
},
{
"name": "someOtherName"
"url": "http://www.url.com/"
"clientreq": true
}, ....
Run Code Online (Sandbox Code Playgroud)
我真的不知道我怎么能读到这个文件..我需要做的是读取行并通过"url"下载文件..我知道如何下载文件等等,但我不知道我如何使用JSON.net读取json文件并循环遍历每个部分,并下载文件..
你能帮忙吗?