Welcome Guest Search | Active Topics | Sign In | Register

How to serialize JSObject ? Options
jason
Posted: Sunday, April 28, 2019 8:58:11 PM
Rank: Newbie
Groups: Member

Joined: 4/28/2019
Posts: 5
Hello,

Is there an easy way to serialize the data in a JSObject?

For example:

Code: C#
EO.WebBrowser.JSObject vals = (EO.WebBrowser.JSObject)webView1.EvalScript("jsobject_with_lots_of_data");
            var json = new JavaScriptSerializer().Serialize(vals);
            Debug.WriteLine(json);


How can I get something like this to work so that I can parse through the data quickly?

Thanks!
eo_support
Posted: Monday, April 29, 2019 2:02:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

There is no way for you to reliably serialize a JSObject on the .NET side. JSObject does not hold the data itself. Instead it holds a "handle" to the actual object in the JavaScript "world". In a way similar to .NET's MarshalByRefObject. Such as by definition it is not serializable. If you wish to pass complex data in between JavaScript and .NET, you should serialize it on the JavaScript side:

https://www.essentialobjects.com/doc/webbrowser/advanced/json.aspx

Thanks!
jason
Posted: Monday, April 29, 2019 4:07:57 PM
Rank: Newbie
Groups: Member

Joined: 4/28/2019
Posts: 5
Thank you! Can't believe I missed this.
eo_support
Posted: Monday, April 29, 2019 4:32:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
You are welcome. Please feel free to let us know if there is anything else.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.