【发布时间】:2019-03-12 15:23:55
【问题描述】:
我编写了一段代码来从货币转换器中获取一个值,如下所示:
WebClient n = new WebClient();
var JsonData = n.DownloadString("http://currencyconverterapi.com/api/v6/convert?q=USD_NRI&compact=ultra&apiKey=");
JsonData = {"USD_INR":69.657026} // Got value result from JsonData
dynamic JObj = JObject.Parse(JsonData);
dynamic JOresult = JObject.Parse(Convert.ToString(JObj.USD_INR)); //Got Error here (Error reading JObject from JsonReader. Current JsonReader item is not an object: Float. Path '', line 1, position 9.)
string JOFilter_Val = Convert.ToString(JOresult.val);
decimal Total = 230 * Convert.ToDecimal(JOFilter_Val);
return Total;
我想通过乘以十进制 230 得到值 '69.657026',并返回最终结果。谁能告诉我我做错了什么,如果可能,请纠正它?
【问题讨论】: