Newtonsoft.Json.JsonWriter
[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4754769.html]
JsonWriter使用:
前台
$.post("Ajax_EstimatedIncome.aspx/GetEstimatedIncomePlus", { ProjectID: m_EstimatedIncomeTEN.ProjectID }, function (json) {
var m = eval('(' + json + ')');
var m_ProjectTEN = eval('(' + m.ProjectTEN + ')');
var m_ProjectPlugTEN = eval('(' + m.ProjectPlugTEN + ')');
var m_CustomersTEN = eval('(' + m.CustomersTEN + ')');
$('#form1 input[name="Stock"]').val(m.Stock);
$('#form1 input[name="EstimatedID"]').val(m_EstimatedIncomeTEN.EstimatedID);
$('#form1 input[name="BluntMonney"]').val(m_EstimatedIncomeTEN.BluntMonney);
$('#form1 input[name="BluntMonneyA"]').val(m_EstimatedIncomeTEN.BluntMonneyA);
$('#form1 input[name="CreateDate"]').val(CreateDate.getFullYear() + "-" + (CreateDate.getMonth() + 1) + "-" + CreateDate.getDate());
$('#form1 input[name="CustomersName"]').val(m_CustomersTEN.ShortName);
$('#form1 input[name="DesignFee"]').val(m_ProjectTEN.DesignFee);
$('#form1 input[name="EstimatedCost"]').val(m_EstimatedIncomeTEN.EstimatedCost);
$('#form1 input[name="EstimatedDate"]').val(EstimatedDate.getFullYear() + "-" + (EstimatedDate.getMonth() + 1));
$('#form1 input[name="EstimatedMonney"]').val(m_EstimatedIncomeTEN.EstimatedMonney);
$('#form1 input[name="EstimatedMonneyA"]').val(m_EstimatedIncomeTEN.EstimatedMonneyA);
$('#form1 input[name="EstimatedRatio"]').val(m_EstimatedIncomeTEN.EstimatedRatio);
$('#form1 input[name="MyProjectNo"]').val(m_ProjectTEN.MyProjectNo);
$('#form1 input[name="ProjectName"]').val(m_ProjectTEN.ProjectName);
$('#form1 input[name="ProjectNum"]').val(m_ProjectTEN.ProjectNum);
$('#form1 input[name="BluntDate"]').val(EstimatedDate.getFullYear() + "-" + (EstimatedDate.getMonth() + 1));
$('#form1 input[name="Remark"]').val(m_EstimatedIncomeTEN.Remark);
$('#form1 input[name="EstimatedRatio"]').val(m_EstimatedIncomeTEN.EstimatedRatio);
$('#form1 input[name="UserName"]').val(m_EstimatedIncomeTEN.UserName);
$('#form1 input[name="CreaterID"]').val(m_EstimatedIncomeTEN.UserID);
if (m_ProjectPlugTEN.ProjectRange == 0)
$('#form1 input[name=ProjectRange]').val('自营');
else if (m_ProjectPlugTEN.ProjectRange == 1)
$('#form1 input[name=ProjectRange]').val('分包');
else if (m_ProjectPlugTEN.ProjectRange == 2)
$('#form1 input[name=ProjectRange]').val('代理');
$('#form1 input[name="ProjectID"]').val(m_EstimatedIncomeTEN.ProjectID);
});
后台
[WebMethod(EnableSession = true)]
public string GetEstimatedIncomePlus()
{
string ProjectID = Request.Params["ProjectID"] == null ? "" : Request.Params["ProjectID"].ToString();
try
{
m_ProjectTEN = bll_ProjectTEO.GetModel(long.Parse(ProjectID));
m_ProjectPlugTEN = bll_ProjectPlugTEO.GetModel(m_ProjectTEN.ProjectPlugID);
m_CustomersTEN = bll_CustomersTEO.GetModel(m_ProjectPlugTEN.CustomersID.Value);
string Stock = "";
DataTable dt_ProjectSum = bll_ProjectSumTEO.GetList_Detail("ProjectID=" + ProjectID);
if (dt_ProjectSum != null && dt_ProjectSum.Rows.Count > )
Stock = dt_ProjectSum.Rows[]["Stock"].ToString();
else
Stock = Global.Precision;
string UserName = string.Empty;
if (ND.Webs.Outsourcing.PlatBase.Business.PlatBaseUserTBO.LoginInfo != null)
UserName = ND.Webs.Outsourcing.PlatBase.Business.PlatBaseUserTBO.LoginInfo.UserName;
int UserID = ;
if (ND.Webs.Outsourcing.PlatBase.Business.PlatBaseUserTBO.LoginInfo != null)
UserID=ND.Webs.Outsourcing.PlatBase.Business.PlatBaseUserTBO.LoginInfo.UserID;
StringWriter sw = new StringWriter();
using (JsonWriter writer = new JsonTextWriter(sw))
{
writer.Formatting = Formatting.Indented;
writer.WriteStartObject();
writer.WritePropertyName("ProjectTEN");
writer.WriteValue(JsonConvert.SerializeObject(m_ProjectTEN));
writer.WritePropertyName("ProjectPlugTEN");
writer.WriteValue(JsonConvert.SerializeObject(m_ProjectPlugTEN));
writer.WritePropertyName("CustomersTEN");
writer.WriteValue(JsonConvert.SerializeObject(m_CustomersTEN));
writer.WritePropertyName("Stock");
writer.WriteValue(Stock);
writer.WritePropertyName("UserName");
writer.WriteValue(UserName);
writer.WritePropertyName("UserID");
writer.WriteValue(UserID);
writer.WriteEndObject();
writer.Flush();
}
sw.Close();
return sw.GetStringBuilder().ToString();
}
catch (Exception ex)
{
return "Error";
}
}
Newtonsoft.Json.JsonWriter的更多相关文章
- Newtonsoft.Json同时对多个时间字段以不同的格式序列化
在博客园潜水多年,学到很多,也进步了很多,在这里说声谢谢,是时候给园友分享一点自己的东西,希望和大家一起进步. 之前有个需求要对一张表的多个时间字段进行不同的格式序列化, 在网上没找到相对较好的解决方 ...
- Newtonsoft.Json序列化和反序列之javascriptConvert.SerializeObject,DeserializeObject,JsonWriter,JsonReader
这里下载:http://www.newtonsoft.com/products/json/安装: 1.解压下载文件,得到Newtonsoft.Json.dll 2.在项目中添加引用.. jav ...
- [.net 面向对象程序设计进阶] (13) 序列化(Serialization)(五) Json 序列化利器 Newtonsoft.Json 及 通用Json类
[.net 面向对象程序设计进阶] (13) 序列化(Serialization)(五) Json 序列化利器 Newtonsoft.Json 及 通用Json类 本节导读: 关于JSON序列化,不能 ...
- Newtonsoft.Json 处理多态类型的反序列化
Newtonsoft.Json的序列化和反序列化很成熟也很好用, 最近在处理多态类型的反序列化中遇到了问题, 反序列化后只能到基类,而得不到也不能转换到子类.从网上查询了一番后,需要写一个创建类型的C ...
- Newtonsoft.Json高级用法(转)
手机端应用讲究速度快,体验好.刚好手头上的一个项目服务端接口有性能问题,需要进行优化.在接口多次修改中,实体添加了很多字段用于中间计算或者存储,然后最终用Newtonsoft.Json进行序列化返回数 ...
- Newtonsoft.Json中的时间格式详解.
Newtonsoft.json是一款不错的序列化反序列化第三方组件,具体如何使用属于基础知识,此处不再讲解.看以下代码: public class OutgameEntity { public str ...
- Json序列化之.NET开源类库Newtonsoft.Json的研究
一.Json简介 JSON(全称为JavaScript Object Notation) 是一种轻量级的数据交换格式.它是基于JavaScript语法标准的一个子集. JSON采用完全独立于语言的文 ...
- 【转】 Newtonsoft.Json高级用法
手机端应用讲究速度快,体验好.刚好手头上的一个项目服务端接口有性能问题,需要进行优化.在接口多次修改中,实体添加了很多字段用于中间计算或者存储,然后最终用Newtonsoft.Json进行序列化返回数 ...
- 组件Newtonsoft.Json实现object2json转换
很多情况下,我们需要把数据类型做一些转换,供其它外部的子系统调用. 最为典型的是生成json格式供javascript作调用. 现成的组件Newtonsoft.Json可以实现object2json之 ...
随机推荐
- Ubuntu 16.04 - 64bit 访问Windows磁盘报错 he NTFS partition is in an unsafe state. Please resume and shutdown Windows fully (no hibernation ...
今天在打开某个磁盘时,突然报错,报错信息如下 原因:Windows 未正常关闭,导致系统误以为存在临时缓存文件 解决方法: http://www.linuxidc.com/Linux/2014-05/ ...
- 折腾ghost。。。
1.启动 NODE_ENV=production node index.js 如果出现启动不了的情况,在该命令加sudo sudo NODE_ENV=production node index.js ...
- java新手笔记26 Frame
0.Calculater package com.yfs.javase; import java.awt.BorderLayout; import java.awt.Button; import ja ...
- android Locat工作日志的使用
#3.Logcat日志工具的使用 日志的等级: error:最高等级,错误信息,红色 warn:比较高,警告信息,橙色 debug:较高,调试信息,蓝色 info:一般,一般信息,绿色 verbose ...
- [leetcode] 406. Queue Reconstruction by Height
https://leetcode.com/contest/6/problems/queue-reconstruction-by-height/ 分析:每个表示成(a,b)的形式,其实找第一个,就是b为 ...
- linq递归
public class Comment { public int Id { get; set; } public int ParentId { get; set; } public string T ...
- 分页 page
1.根据条件计算出数据的总数 2.import(page类); 3.实例化分页类 4.设置相关的参数 5.调用show()方法 // 导入分页类 import('ORG.Util.Page');$p ...
- 在Windows Server 2008上部署SVN代码管理总结
这段时间在公司开发Flex程序,所以使用TortoiseSVN作为团队代码管理器,今天在公司服务器上部署SVN服务器,并实验成功,总结如下: 服务器环境: 操作系统:Windows Server 20 ...
- 企业生产环境下不同业务的linux分区建议
常规分区方案: /boot: 100M swap:内存的1至1.5倍 / : 剩余硬盘大小 DB及存储:有大量重要的数据 /boot : 100M swap: 内存的1至1.5倍,如果内存大于等于1 ...
- EventLog组件
1.使用EventLog组件读写事件日志 SourceExists方法 确定事件源是否已在本地计算机上注册 DeleteEventSource方法 用于从事件日志中移除应用程序的事件源注册 pri ...