0

I have created the following public class colModelClass so I can deserialize the colModel string for my 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; }
}

The problem is, formatoptions isn't a string. It is a json object with an unlimited number of possible items. Not only can it contain each standard formatoptions item that ships with jqgrid, but it can contain custom options as well.

Which Type do I use for formatoptions that will allow an object like this:

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

or this

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

or any other number and combination of options (that won't require me to update my class if I add additional options)?

Or, how do I create a formatoptionsClass class that will accept any string, bool, int, etc so it can build the class dynamically?

3
  • hmm, now I feel silly. I didn't even think to try that.
    – davids
    Commented Dec 18, 2012 at 1:22
  • @csg works perfectly, thanks. If you put that as an answer, I will accept it since the question has to remain.
    – davids
    Commented Dec 18, 2012 at 1:30
  • Could give an example how to use as object for formatoption Commented Jun 2, 2015 at 15:03

2 Answers 2

0

Like I said in comment - put it as Object.

0

You must specify the datatype as 'Object' for unknown types and especially for JSON object.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.