c# - Passing JSON from Javascript Callback in JINT -


i have library allows developer extend business rule triggers via javascript. there function allows developer (in javascript) subscribe event , pass delegate "call me when happens".

i able successfully, running snag when function attempts pass json or javascript object c# layer.

basically code functions unit test:

func<string, jsvalue> callback = null; func<func<string, jsvalue>, object> registercallback = (o) => callback = o; engine engine = new engine()     .setvalue("registercallback", registercallback)     .execute("registercallback(function(parameter) { return { \"passed\": parameter }; });"); assert.isnotnull(callback); var result = callback("test"); 

i c# variable "result" have jsvalue or other object contains data method throws exception: must implement iconvertable on last line.

i can verify "callback" set delegate of appropriate type: jint.native.jsvalue lambda_method(system.runtime.compilerservices.closure, system.string)}

and don't have issue if pass null. i'm sure there tiny (headbang once figure out) missing piece...

change jsvalue system.dynamic.expandoobject. type of result, , can safely cast idictionary<string, object>.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -