开发者

how to make script# preserve case of json records

开发者 https://www.devze.com 2023-03-18 08:19 出处:网络
I have [Imported] public sealed class ServerResult : Record { public string Message; public int Result; } And my json server method does

I have

[Imported]
public sealed class ServerResult : Record
{

    public string Message;
    public int Result;
}

And my json server method does

return Json(new { Result = result, Message = message }, JsonRequestBehavior.AllowGet);

but the js generated for

   jQuery.PostRequest<ServerResult>("status", null,
               delegate(ServerResult data)
               {
                    if(data.Result == 3)...
               }, "json");

says

          if(data.result === 3) ....

the case has been forced to all lowercase开发者_StackOverflow社区; which doesnt match what came over the wire

I can work round this by using lower case names in the c# but this breaks all my naming conventions.

PS - Nikhil - pls open source scipt#

version 0.7.2


To disable automatic changes to casing you can use [PreserveCase].

Like so:

[Imported]
public sealed class ServerResult : Record
{
    [PreserveCase]
    public string Message;
    [PreserveCase]
    public int Result;
}

You can also use [ScriptName("MyExactNameInJavaScript")] to be explicit about differences beyond just casing.

0

精彩评论

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

关注公众号