From this page I can see how to get a JSObject
from a JSValue
in C++. Is there a similar way to do so in .NET? The ToObject()
method doesn't seem to exist.
Asked
Active
Viewed 733 times
1

JoeB
- 2,743
- 6
- 38
- 51
1 Answers
1
Just cast the argument from a JSValue
to JSObject
protected virtual void MyBoundMethod(object sender, JavascriptMethodEventArgs e)
{
JSObject temp;
JSValue value;
if (e.Arguments == null || e.Arguments.Length == 0)
return;
if (JSValue.Null != e.Arguments[0] && e.Arguments[0].IsObject)
{
temp = (JSObject)e.Arguments[0];
value = temp["someProperty"];
}
}

Steve Jansen
- 9,398
- 2
- 29
- 34
-
What if you do not know the name of the property? – Sjoerd222888 Jan 12 '15 at 09:49
-
See [Awesomium::JSObject Class Reference](http://awesomium.com/docs/1_7_0/cpp_api/class_awesomium_1_1_j_s_object.html). Try `GetMethodNames` or `HasProperty` or `HasMethod`. – Steve Jansen Jan 12 '15 at 16:56
-
Your link points to the C++ API. How can I find out the property name with HasProperty? Test for all possible variable names? I just found [this](http://docs.awesomium.net/html/M_Awesomium_Core_JSObject_GetPropertyNames.htm) but unfortunatly this yields an InvalidOperation exception. – Sjoerd222888 Jan 12 '15 at 17:27
-
The Awesomium API is similar between C++ and .Net. See http://docs.awesomium.net/html/T_Awesomium_Core_JSObject.htm . Confirm your version of Awesomium supports these methods if you are not using the latest bits. – Steve Jansen Jan 14 '15 at 11:37
-
I found it. But as I just said, I think I can only find the property names by calling 'myJSObject.GetPropertyNames()' but this yields an InvalidOperation exception. – Sjoerd222888 Jan 14 '15 at 12:41