-3
public class 2500113075262000    {
    public string pair { get; set; } 
    public string type { get; set; } 
    public double amount { get; set; } 
    public int rate { get; set; } 
    public string timestamp_created { get; set; } 
    public int status { get; set; } 
}

public class Return    {
    public 2500113075262000 2500113075262000 { get; set; } 
}

public class Root    {
    public int success { get; set; } 
    public Return @return { get; set; } 
}

class 2500113075262000 is constantly changing, this is the order ID, like deserialize

{"success":1,"return":{"2500113075262000":{"pair":"eth_rur","type":"sell","amount":0.00110569,"rate":46100,"timestamp_created":"1608918997","status":0}}}
4
  • 1
    It would really help if you'd show the JSON you're trying to deserialize. I suspect that you actually want a Dictionary<string, Order> or something similar, but it's hard to tell just from what you've shown us.
    – Jon Skeet
    Commented Dec 26, 2020 at 10:34
  • {"success":1,"return":{"2500113075262000":{"pair":"eth_rur","type":"sell","amount":0.00110569,"rate":46100,"timestamp_created":"1608918997","status":0}}}
    – SanekXXX4
    Commented Dec 26, 2020 at 10:54
  • Please edit your question to show the JSON, rather than putting it as a comment.
    – Jon Skeet
    Commented Dec 26, 2020 at 10:55
  • a constantly changing class - i'd strongly recommend changing your code so your class stays the same. Commented Dec 26, 2020 at 11:02

1 Answer 1

1

It looks like it's only the key - presumably the order ID - which is changing. I would suggest removing your Return class entirely, and changing your Root class to have a Dictionary<string, Order>. I'd also suggest writing your classes with idiomatic .NET property names, and using JsonPropertyAttribute to specify the representation in the JSON. So it would be something like this:

public class Order
{
    [JsonProperty("pair")]
    public string Pair { get; set; }

    [JsonProperty("type")]
    public string Type { get; set; }

    // etc, other properties
}

public class Root
{
    [JsonProperty("success")]
    public int Success { get; set; }

    [JsonProperty("return")]
    public Dictionary<string, Order> Returns { get; set; }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.