using System;
using System.Data;
using System.Web;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;
public partial class project_manage_TJ : CommonPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string ObjectToJson(object obj)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
MemoryStream stream = new MemoryStream();
serializer.WriteObject(stream, obj);
byte[] dataBytes = new byte[stream.Length];
stream.Position = 0;
stream.Read(dataBytes, 0, (int)stream.Length);
return Encoding.UTF8.GetString(dataBytes);
}
}
对象类型转json类型
最新推荐文章于 2024-08-04 03:46:33 发布