使用DataContractJsonSerializer序列化object []

时间:2018-03-08 09:25:25

标签: c# json serialization

可以使用DataContractJsonSerializer序列化对象[]的类型吗?

private string TryToSerialize(object toSerialize)
{        
     try
     {
         using (System.IO.MemoryStream writer = new System.IO.MemoryStream())
         {
             System.Runtime.Serialization.Json.DataContractJsonSerializer se =
                    new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(object[]));
                ser.WriteObject(writer, toSerialize);                    
         }
     }
     catch
     {                
     }
}

0 个答案:

没有答案