gpt4 book ai didi

C# JSON Parse 在解析 JSON 数组时给出错误 'System.ArgumentNullException'

转载 作者:行者123 更新时间:2023-11-30 20:35:34 25 4
gpt4 key购买 nike

我正在尝试解析这个 JSON:

{"error":[],"result":{"XETHXXBT":{"a":["0.023769","64","64.000"],"b":["0.023756","42","42.000"],"c":["0.023756","1.21518360"],"v":["74038.22109284","130984.00945101"],"p":["0.023689","0.006974"],"t":[1272,2332],"l":["0.023440","0.023440"],"h":["0.024091","0.024669"],"o":"0.024084"}}}

我要获取的那条数据是

"c":["0.023756","1.21518360"],

更重要的是,“c”的第一个值。我使用的代码是:

    JObject jObject = JObject.Parse(json);
double balance = (double)jObject["c"];

我做错了什么?我怎样才能得到“c”数组的第一个值?

谢谢!

这是完整的错误报告:http://pastebin.com/4S204aUG

最佳答案

要到达 c,请执行以下操作:

var o = JObject.Parse(<yourjsontext>);
var result = o["result"];
var XETHXXBT = result["XETHXXBT"];
var c = XETHXXBT["c"];

var value1 = (double) c[0];
var value2 = (double) c[1];

关于C# JSON Parse 在解析 JSON 数组时给出错误 'System.ArgumentNullException',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37766181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com