Using the following class definition, you can deserialize directly to C# values (as strings). From there, you can convert it down further, but this should preserve the values fine. Tested on my own machine and the values work fine.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace TinkeroonieCSharp
{
class UserJSON
{
[JsonProperty]
public string id;
[JsonProperty]
public string name;
[JsonProperty]
public string symbol;
[JsonProperty]
public string rank;
[JsonProperty]
public string price_usd;
[JsonProperty]
public string price_btc;
[JsonProperty]
public string twenty_four_hour_volume_usd;
[JsonProperty]
public string market_cap_usd;
[JsonProperty]
public string available_supply;
[JsonProperty]
public string total_supply;
[JsonProperty]
public string max_supply;
[JsonProperty]
public string percent_change_1h;
[JsonProperty]
public string percent_change_24h;
[JsonProperty]
public string percent_change_7d;
[JsonProperty]
public string last_updated;
}
class Program
{
static void Main(string[] args)
{
using (var webClient = new System.Net.WebClient())
{
var json = webClient.DownloadString("https://api.coinmarketcap.com/v1/ticker/808coin/");
List<UserJSON> array = JsonConvert.DeserializeObject<List<UserJSON>>(json);
var name = array[0].name;
Console.WriteLine(name);
}
}
}
}
It's a little ugly but it gets the point across. Look over the following question HERE to have more info on the method I used!
The reason an error was occurring was because you were deserializing it down into the string of the entire JSON file, so attempting to index name would always return null, since it is just a string variable. By segmenting the deserialize down into each individual property of the JSON file, we can access anything we need without hassle at the point of deserialization. So you could go
thing = JsonConvert.DeserializeObject<UserJSON>(json).name
to cut down on your lines, if needed. Unadvised, though. Best cache it for later! :D