MattyAB MattyAB - 1 year ago 67
JSON Question

C# JSON Parse gives error 'System.ArgumentNullException' when parsing JSON array

I'm trying to parse this JSON:


The piece of data I want to get is


More to the point, the first value of "c". The code I am using is:

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

What am I doing wrong? How can I just get the first value of the "c" array?


Here is the full error report:

Answer Source

To get to c do the following:

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download