I’m creating a winmd file for use in Windows 8 development. I want to have a great JavaScript (WinJS) experience but can’t work out how to have my methods except raw JSON, for example I would like developers to code like this in WinJS:
bar.foo({ bar: 19 })
And inside my C# library I would have something like this
public sealed class Bar
{
public void Foo(JsonObject jsonObject)
{
This compiles but when I try to call foo from WinJS I get an error saying the signature of the method is invalid. I’m assuming this is because it exposes a ‘managed’ type Windows.Data.Json.JsonObject.
Any ideas how I can work with JSON passed from the WinJS world into .NET (within a WinMD).
I think it’s not possible, at least in the Developer Preview.
I created a C# method that has an
objectparameter with the assumption that any object that can be converted from JS form to .Net form through WinRT will be able to go through.And it works for arrays: a JS array will be passed in as
object[]. But if I try to pass a JSON object, a “Type mismatch” error is thrown. This is why I think it’s not possible.I also tried object created using the
WinJS.Class.define()function, but that didn’t work either.