Answer the question
In order to leave comments, you need to log in
How to deserialize JSON to C# class object?
Good time of the day. Help me figure out how to deserialize the response from the server into such a class, well, or I'm not thinking correctly and I need to write another class.
public class AllPair
{
public string name;
public List<CurrencyPair> Pair;
}
public class CurrencyPair
{
public int timestamp;
public List<Deal> asks;
public List<Deal> bids;
}
public struct Deal
{
public decimal price;
public decimal quantity;
}
{
"LTC/BTC": {
"timestamp": 1441877692694,
"asks": [
[
"0.01240280",
"1018.43939000"
],
[
"0.01241000",
"633.12852530"
],
[
"0.01242000",
"1012.19000000"
]
],
"bids": [
[
"0.01210890",
"247.07000000"
],
[
"0.01210000",
"944.49586780"
],
[
"0.01210000",
"590.30991000"
]
]
},
"LTC/RUR": {
"timestamp": 1441877692694,
"asks": [
[
"206.35000000",
"42.00000000"
],
[
"206.40000000",
"16.00000000"
]
],
"bids": [
[
"196.36000000",
"86.61000000"
],
[
"196.29570000",
"50.27000000"
],
[
"196.16570000",
"50.30655664"
]
]
}
}
Answer the question
In order to leave comments, you need to log in
1 - https://github.com/JamesNK/Newtonsoft.Json de facto standard for .Net
2 - there is a native
serializer /deserializer , but less convenient
class, that is, without a preliminary description of the structure, without contracts, etc.... just recently I remembered this... and could not find that code)) ... I went to look at Newtonsoft ... and in the end I was happy like an elephant, with everything I recommend, the docks are simple, many examples, almost no need to read in English, a lot of simple example code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question