我已经花了两天时间对代码样本等进行"最好的"工作,尝试将一个非常大的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) 我在一些代码中有这行我想复制到我的控制器,但编译器抱怨
"服务器"名称在当前上下文中不存在
var UploadPath = Server.MapPath("~/App_Data/uploads")
Run Code Online (Sandbox Code Playgroud)
如何在ASP.NET Core中实现等效?
在尝试在C#中反序列化JSON时发现在获取信息方面存在一些困难.
我有以JSON格式返回的Google自定义搜索结果.我只是想检查一下我的步骤,并确定尝试反序列化它的顺序.这是正确的吗?
JavaScriptSerializer()类和
deserialize方法提取相关位.我认为我将遇到的一个问题是我不需要返回所有数据,只需要html链接.我怎样才能做到这一点?
UPDATE
我已使用以下JSON代码段和C#代码更新了我的问题.我想将字符串'links'输出到控制台,但它似乎不起作用.我想我错误地定义了我的课程?
Google自定义搜索中的JSON
handleResponse({
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q\u003d{searchTerms}&num\u003d{count?}&start\u003d{startIndex?}&hr\u003d{language?}&safe\u003d{safe?}&cx\u003d{cx?}&cref\u003d{cref?}&sort\u003d{sort?}&alt\u003djson"
},
"queries": {
"nextPage": [
{
"title": "Google Custom Search - lectures",
"totalResults": 9590000,
"searchTerms": "lectures",
"count": 1,
"startIndex": 2,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"cx": "017576662512468239146:omuauf_lfve"
}
],
"request": [
{
"title": "Google Custom Search - lectures",
"totalResults": 9590000,
"searchTerms": "lectures",
"count": 1,
"startIndex": 1,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"cx": "017576662512468239146:omuauf_lfve"
}
]
},
"context": {
"title": "Curriculum",
"facets": …Run Code Online (Sandbox Code Playgroud)