Passing JSON objects to and from C# #3415
Replies: 1 comment 10 replies
-
If you passed an object to a method as a parameter then there's no JSON involved. The default type for an object is https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.expandoobject?view=net-5.0 Which you can cast to System.Collections.Generic.IDictionary<string,object> should you choose to. You can use the dynamic keyboard with ExpandoObject. Rather than describe code in future please provide examples of both your JavaScript and c#.
You can return a POCO and you will get an object in JavaScript. Again no JSON is actually used.
No. What exactly are you trying to achieve? |
Beta Was this translation helpful? Give feedback.
-
Hi All, I am new to "playing" with CefSharp so am feeling my way. I have successfully embedded it within a WinForm application. I have called a C# method from JavaScript and invoked a delayed callback in JS. I was trying to pass a JSON object into the C# method and added a parameter of type Object to receive it so I could determine the type, it arrives and "GetType()" returns Dictionary'2... I guessed at Dictionary<string,string> but this results in an invalid cast. Can anyone tell me the correct type to use? I would also like to return a value that JS would see as a JSON object.
Also, is there a "promise" equivalent to "IJavascriptCallback"?
public void TestCallback(IJavascriptCallback javascriptCallback, object param)
Beta Was this translation helpful? Give feedback.
All reactions