相关疑难解决方法(0)

在C#中读取和解析Json文件

我已经花了两天时间对代码样本等进行"最好的"工作,尝试将一个非常大的JSON文件读入c#中的数组中,以便稍后将其拆分为二维数组进行处理.

我遇到的问题是我找不到任何人做我想做的事情的例子.这意味着我只是想编写一些希望最好的代码.

我已经成功地完成了一些工作:

  • 读取文件Miss out headers并仅将值读入数组.
  • 在数组的每一行上放置一定数量的值.(所以我以后可以把它分成2d数组)

这是通过下面的代码完成的,但是在输入几行到数组后它会崩溃程序.这可能与文件大小有关.

// 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)

c# parsing json large-files

207
推荐指数
9
解决办法
49万
查看次数

使用C#和JSON.net读取JSON文件

我很难理解如何使用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文件并循环遍历每个部分,并下载文件..

你能帮忙吗?

c# json json.net

5
推荐指数
2
解决办法
3万
查看次数

标签 统计

c# ×2

json ×2

json.net ×1

large-files ×1

parsing ×1