开发者

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.IsCu开发者_StackOverflow中文版stomQuote;

        return jsObject;

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜