C#C
C#3y ago
9 replies
.tree

❔ Models for JSON from API

In Tim Coreys video he had an API with this sort of JSON structure:
results:
        sunrise: "value"
        sunset: "value"

For this he created two models, one for the actual keys called
SunModel
, and one for the
results
, which has a field of type
SunModel
called Results.



Now I have this API that I want to call:

times:
        2023-10-29:
                0: "value"
                 1: "value"


So I have one more layer, what would be the best approach for this? To make one Model for
times
, one for
2023-10-29
and one for the actual keys
0
and
1
?

Also, since I can't name the variable in my model class
0
, how do I tell my application to get this specific value? Can I index it?
Was this page helpful?