0

我创建了以下公共类colModelClass,因此我可以为我的 colModel 字符串反序列化jqgrid

public class colModelClass
{
    public string name { get; set; }
    public string index { get; set; }
    public string jsonmap { get; set; }
    public bool editable { get; set; }
    public bool sortable { get; set; }
    public int width { get; set; }
    public string align { get; set; }
    public bool hidden { get; set; }
    public string sorttype { get; set; }
    public string formatter { get; set; }
    public string formatoptions { get; set; }
}

问题是,formatoptions不是字符串。它是一个json具有无限数量的可能项目的对象。它不仅可以包含formatoptions随附的每个标准项目,jqgrid还可以包含自定义选项。

Type我使用哪个formatoptions将允许这样的对象:

{ "srcformat": "m/d/Y", "newformat": "m/d/Y" }

或这个

{ "decimalSeparator":".","thousandsSeparator":"," }

或任何其他数量的选项和组合(如果我添加其他选项,则不需要我更新我的课程)?

或者,我如何创建一个formatoptionsClass可以接受任何字符串、bool、int 等的类,以便它可以动态构建该类?

4

2 回答 2

0

对于未知类型,尤其是 JSON 对象,您必须将数据类型指定为“对象”。

于 2012-12-18T04:44:31.543 回答
0

就像我在评论中说的 - 把它作为对象。

于 2012-12-18T06:17:10.943 回答