我有很多课,其中一类是以下
public class DeletePatientCommand
{
public int Id { get; set; }
}
我进行了以下WCF操作:
object command = JsonConvert.DeserializeObject(
"{\"DeletePatientCommand\":{\"Id\":5}}",
typeof(DeletePatientCommand));
对象已反序列化,但是其Id
始终是0
而不是5
。
答案 0 :(得分:0)
正如Steven先生所说,我发布的JSON无效。 JSON不包含类型名称。以下作品:
class Element {
public:
Element() {};
Element(std::string s, int a) { name = s; value = a; };
Element(std::string s) { name = s; value = 0; };
...
std::string return_name() { return name; };
private:
std::string name;
int value;
};
std::string fun(Element x) { return x.return_name(); };
聊天还包含有用的信息。