Lower camel case style is convention in JavaScript. Default is not lower camel case style when I pass object from .NET to JavaScript in CefSharp.
public void GetTestDataWithCallback(IJavascriptCallback callback)
{
callback.ExecuteAsync(new TestData
{
Id = 1,
Name = "Johnny",
Test = new TestData
{
Id = 2,
Name = "Mary"
}
});
}
The above code will receive in JavaScript:
{"Id":1,"Name":"Johnny","Test":{"Id":2,"Name":"Mary","Test":null}}
Is there any way to use lower camel case style?
Thanks for reply.
CodePudding user response:
You can control naming via the JavascriptObjectRepository.NameConverter
The code look something like the following.
chromiumWebBrowser.JavascriptObjectRepository.NameConverter = new CamelCaseJavascriptNameConverter();
Make sure to set the property shortly after the ChromiumWebBrowser instance is created.