how to make script# preserve case of json records
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.
精彩评论