C# - Smartsheet - GetColumn() method data into class list

96 views Asked by At

I have the following class built out

public class DiscColConfig
{
    public long id { get; set; }
    public int index { get; set; }
    public string title { get; set; }
    public string type { get; set; }
    public List<string> options { get; set; }
    public bool locked { get; set; }
    public bool lockedForUser { get; set; }
    public bool validation { get; set; }
    public int width { get; set; }
}

this will be used to store the deserialized json results from the following method:

public static AreaColConfig GetAreaColConfig(long sid, long cid, SmartsheetClient ss)
{
        Column config = ss.SheetResources.ColumnResources.GetColumn(
        sid,
        cid,
        null
        );
        string json = config.ToString();
        AreaColConfig result = JsonConvert.DeserializeObject<AreaColConfig>
        (json);
        return result;
}

how should i properly call config's result into a string variable to deserialize into the class for storage?

If there is any additional information that would help let me know - first time running into smartsheet and its not playing very nice -_-

1

There are 1 answers

0
stmcallister On

Not a C# expert, but was able to get what you're looking for by using JavaScriptSerializer.

JavaScriptSerializer js = new JavaScriptSerializer();  
string json = js.Serialize(config);