Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Call JS function with object as parameter

0
0
Hi,

I need to call a function in my Javascript which takes a Javascript object as parameter. The catch is that the property names of the object are something like "a.b" or "foo.bar" and they are dynamic, so I cannot create a static object to call with.

Is there any way to call the function with a Dictionary<string, object> and have it converted to a Javascript object automatically?

So far I've done a workaround:
  1. Create the Dictionary<string, object>, add values
  2. Convert it to JSON
  3. Call the Javascript function
  4. In the function use JSON.parse to turn it into a Javascript object
It works, but it's clunky.

Thanks a lot!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images