类:
public class UploadDocumentItem
{
public UploadDocumentItem()
{ }
public string DocMuid { get; set; }
public string DocName { get; set; }
public string UploadDate { get; set; }
}
json格式化:
UploadDocumentItem objUploadDocumentItem = new UploadDocumentItem();
objUploadDocumentItem.DocMuid = Guid.NewGuid().ToString();//生成一个新的MUID,保证文件名称的唯一性
objUploadDocumentItem.DocName = file.FileName;
objUploadDocumentItem.UploadDate = DateTime.Now.ToShortDateString();
context.Response.Write(new JavaScriptSerializer().Serialize(objUploadDocumentItem));
js解析json:
var res= $.parseJSON(response); //此时res即是一个UploadDocumentItem 对象,可以res.DocMuid 使用