Open astrohart opened 3 years ago
So I got away with using an indexer:
namespace Nomics.Api.Models
{
public class CurrenciesTicker
{
/* ... */
public The1_D this[string index]
{
get
{
The1_D result;
switch (index)
{
case "1d" :
result = The1D;
break;
case "7d":
result = The7D;
break;
case "30d":
result = The30D;
break;
case "365d":
result = The365D;
break;
case "ytd":
result = Ytd;
break;
default:
throw new ArgumentOutOfRangeException(nameof(index));
}
return result;
}
}
/* ... */
}
}
It depends on knowing the value set in advance, but the input JSON is definitely something I think could benefit from a heuristic that says, if I have 1 or more nested objects named by different properties, it would be cool to have Quicktype automatically generate the indexer as needed.
Hi,
I have the input JSON
The bottom 5 nested objects are clearly elements in a
Dictionary<string, object>
of some sort, but QuickType seems to be clueless about it. The code it generates is thus:The
The1_D
class is not what I expect. I expect a class like that, but then aDictionary<string, The1_D>
in theCurrenciesTicker
class to appear. I have theDetect maps
feature of QuickType toggled on. It does not appear to work.