【发布时间】:2015-12-04 09:23:01
【问题描述】:
我正在尝试从这个 json 文件中读取,问题是我没有得到任何信息,而且1357 总是在变化。
这是文件的一部分
{
"result": {
"1357": {
"Random": "4NUX4oFJZEHLbXH5ApeO4",
"Random2": "Co04DEVlxkKgpou-6kej",
我用来阅读的课程
using System;
using System.IO;
using Newtonsoft.Json;
namespace MyNamespace
{
public class ReadRandom
{
public static ReadRandom Fetch(string filename)
{
TextReader reader = new StreamReader(filename);
string json = reader.ReadToEnd();
reader.Close();
ReadRandomResult AssetClassInfoResult = JsonConvert.DeserializeObject<ReadRandomResult>(json);
return AssetClassInfoResult.result;
}
[JsonProperty("Random")]
public string Random { get; set; }
[JsonProperty("Random2")]
public string Random2 { get; set; }
protected class ReadRandomResult
{
public ReadRandom result { get; set; }
}
}
}
其中一个答案的错误
Exception thrown: 'System.ArgumentException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
我正在尝试阅读“icon_url” 在那之下的一些事情。 抱歉,在我认为我不需要它之前我没有把它全部发布 在示例中使用它时,您发布了一个更改键到正确的键,我仍然崩溃。
【问题讨论】: