【发布时间】:2017-03-03 17:08:21
【问题描述】:
一些强类型类:
public class A
{
public C Process(B b)
{
return new C()
{
Output = b.Property + " bar!"
};
}
}
public class B
{
public string Property {get;set;}
}
public class C
{
public string Output {get;set;}
}
输入为 JSON 字符串:
string input = "{\"Property\":\"foo\"}";
我想要的是,如果我有 A 的实例作为对象,我想调用这个 JSON 并检索对象输出:
object instanceOfA = new A();
object result = instanceOfA.GetType().GetMethod("Process").Invoke(instanceOfA, new []{ /*json here?*/});
所以,它基本上类似于对一些普通参数的一些 JavaScript 调用。
【问题讨论】: