开发者

How can I use a keyword as a property name?

开发者 https://www.devze.com 2023-01-30 15:34 出处:网络
I have been serializing anonymous types into json quite successfully until now.. dynamic jsObject; jsObject = new ExpandoObject();

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

精彩评论

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