_Engine.Script.test( new { test = 123, cat = "lolcat" } );
This outputs the following to JavaScript:
{"Equals":{},"GetHashCode":{},"ToString":{},"GetType":{},"test":123,"cat":"lolcat"}
As you can see also the methods are being converted to Json properties. Is it possible (with as little boilerplate syntax as possible) to only send the properties? Same goes for Expando-like objects.
Below here works, and I can replace a bit of boilerplate with some extension methods, but it would be nice if I can completely get rid of all boilerplate.
var js = _Engine.Evaluate( "eval(" + JSONSerializer.Serialize(new { test = 123, cat = "lolcat" }) + ")" );
_Engine.Script.test( js );
How about using ClearScript's
PropertyBag
? For example,Or, if you're using C# 6 or later,