大家晚上好,反序列化JSON填充陣列,並從URL進行計算的值
我的工作有一些retrive JSON值的應用程序(例如0.00004582)(此例如https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-NEO&tickInterval=day)與Microsoft Visual C#2017.
我能夠讀取URL,並且我設置了一個類來定義JSON值是如何讀取的,我的邏輯建議我必須將它們存儲在變量中,然後使用他們,但問題是我不能讓程序正確讀取值,並且我不知道如何使用這些對象來進行我的計算。
這是Data.cs的代碼類
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApp3
{
public class Data
{
internal IEnumerable<object> data;
public double O { get; set; }
public double H { get; set; }
public double L { get; set; }
public double C { get; set; }
public double V { get; set; }
public string T { get; set; }
public double BV { get; set; }
}
public class RootObject
{
public bool success { get; set; }
public string message { get; set; }
public List<Result> result { get; set; }
}
}
雖然這是從Form1的
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using Newtonsoft.Json;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
var client = new WebClient();
var text = client.DownloadString("https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-NEO&tickInterval=day");
var result = JsonConvert.DeserializeObject<Data>(text);
foreach (var data in result.C)
{
Console.WriteLine(result);
}
}
}
}
代碼我能做些什麼?你能否指點我一些很好的資源來理解要做什麼?
非常感謝。
感謝您的回覆!正是我在找什麼。 您可以請告訴我您認爲這是對這類數據進行計算的最佳方式嗎? – Revengeic3