我需要输出这个json:
{
white: [0, 60],
green: [60, 1800],
yellow: [1800, 3000],
red: [3000, 0]
}
我正在尝试思考一个像这样的模型:
public class Colors
{
public int[] white { get; set; }
public int[] green { get; set; }
public int[] yellow { get; set; }
public int[] red { get; set; }
}
但是属性名称可能会更改,例如白色现在可以变为灰色等。
有任何线索吗?
Dictionary<string, int[]>
怎么样?你根本不需要那个Colors类。 - maccettura"
包装字段名称。 - Markiian Benovskyi"white": [0, 60],"green": [60, 1800]
等等。除此之外,你正在寻找一个简单的字典,就像@maccettura评论的那样。 - Lasse V. Karlsendynamic
。 - Panagiotis Kanavos