使用WriteObject时的异常

时间:2014-05-22 08:00:36

标签: c# json datacontractserializer

我正在尝试向Json流添加一些参数。但是,当我尝试WriteObject时,获得了一个重要的选择。我究竟做错了什么?

Stream responseStream = e.Result;

Params par = new Params();
par.id = "1";
par.jsonrpc = "2.0";
par.method = "getPosts";
par.param = new Param { page = "0"};

DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Params));
ser.WriteObject(responseStream, par);
Params response = (Params)ser.ReadObject(responseStream);

0 个答案:

没有答案