Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use a keyword as a property name?

I have been serializing anonymous types into json quite successfully until now..

        dynamic jsObject;

        jsObject = new ExpandoObject();
        jsObject.dataUrl = Controller.Url.Action("loadall", "residuals", new { EditionId = EditionId, Country = Country, ModelYear = ModelYear, MakeId = ModelId, StyleId = style.Id });
        jsObject.id = style.Id;
        jsObject.text = style.Name;
        jsObject.iconCls = "sprite-toolbar-flag-us";
        jsObject.checked = false; // <---<< the problem is here
        jsObject.leaf = true;
        jsObject.IsCustomQuote = style.IsCustomQuote;

        return jsObject;

Is there a workaround? I'm gonna try to serialize a dictionary into a json object if not..

like image 798
djmc Avatar asked Dec 16 '10 00:12

djmc


1 Answers

You would use the "verbatim" operator @: jsObject.@checked = false;

like image 91
Gabe Avatar answered Sep 22 '22 18:09

Gabe