csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C#.
/// <summary>
///參考: http://james.newtonking.com/json/help/index.html#
/// 塗聚文(Geovin Du) 20141228
/// 捷為工作室
/// </summary>
public partial class _Default : System.Web.UI.Page
{
Geovindu_TimeLineProjectInfo geovindu_TimeLineProjectInfo = new Geovindu_TimeLineProjectInfo();
Geovindu_TimeLineProjectBLL geovindu_TimeLineProjectBLL = new Geovindu_TimeLineProjectBLL();
Geovindu_TimeLineAssetInfo geovindu_TimeLineAssetProjectInfo = new Geovindu_TimeLineAssetInfo(); List<Geovindu_TimeLineDataInfo> selectGeovindu_TimeLineDataProject = new List<Geovindu_TimeLineDataInfo>(); Geovindu_TimeLineDataInfo geovindu_TimeLineDataInfo = new Geovindu_TimeLineDataInfo();
Geovindu_TimeLineAssetInfo geovindu_TimeLineAssetDataInfo = new Geovindu_TimeLineAssetInfo(); Geovindu_TimeLineAssetBLL geovindu_TimeLineAssetBLL = new Geovindu_TimeLineAssetBLL();
Geovindu_TimeLineDataBLL geovindu_TimeLineDataBLL = new Geovindu_TimeLineDataBLL();
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
try
{
geovindu_TimeLineProjectInfo = geovindu_TimeLineProjectBLL.SelectGeovindu_TimeLineProject(1);
geovindu_TimeLineAssetProjectInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetProject(1);
selectGeovindu_TimeLineDataProject = geovindu_TimeLineDataBLL.SelectGeovindu_TimeLineDataProject(1);
for (int i = 0; i < selectGeovindu_TimeLineDataProject.Count; i++)
{
selectGeovindu_TimeLineDataProject[i].TimeLineDataAssetInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetData(selectGeovindu_TimeLineDataProject[i].TimeDataID);
} //context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
geovindu_TimeLineProjectInfo = geovindu_TimeLineProjectBLL.SelectGeovindu_TimeLineProject(1);
geovindu_TimeLineAssetProjectInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetProject(1);
selectGeovindu_TimeLineDataProject = geovindu_TimeLineDataBLL.SelectGeovindu_TimeLineDataProject(1);
for (int i = 0; i < selectGeovindu_TimeLineDataProject.Count; i++)
{
selectGeovindu_TimeLineDataProject[i].TimeLineDataAssetInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetData(selectGeovindu_TimeLineDataProject[i].TimeDataID);
} JObject rss =
new JObject(
new JProperty("timeline",
new JObject(
new JProperty("headline", geovindu_TimeLineProjectInfo.TimeHeadline),
new JProperty("type", geovindu_TimeLineProjectInfo.TimeType),
new JProperty("text", geovindu_TimeLineProjectInfo.TimeText),
new JProperty("startDate", geovindu_TimeLineProjectInfo.TimeStartDate.ToString("yyyy,MM,dd")),
new JProperty("asset",
new JObject(
new JProperty("media", geovindu_TimeLineAssetProjectInfo.TimeAssetMedia),
new JProperty("credit", geovindu_TimeLineAssetProjectInfo.TimeAssetCredit),
new JProperty("caption", geovindu_TimeLineAssetProjectInfo.TimeAssetCaption))),
new JProperty("date",
from p in selectGeovindu_TimeLineDataProject
orderby p.TimeDataHeadline
select new JObject(
new JProperty("startDate", p.TimeDataStartDate.ToString("yyyy,MM,dd")),
new JProperty("headline", p.TimeDataHeadline),
new JProperty("text", p.TimeDataText),
new JProperty("asset",
new JObject(
//geovindu_TimeLineAssetDataInfo=geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetData(p.TimeDataID)
new JProperty("media", p.TimeLineDataAssetInfo.TimeAssetMedia),
new JProperty("credit", p.TimeLineDataAssetInfo.TimeAssetCredit),
new JProperty("caption", p.TimeLineDataAssetInfo.TimeAssetCaption) )))))));
Response.Write(rss.ToString());
File.WriteAllText(Server.MapPath("geovindu.json"), rss.ToString()); }
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
} }
}
}
csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C#.的更多相关文章
- Array(数组)与Json String (Json字符串) 的相互转换
1.Array转换成Json String function jsonToString(arr) { var s = ""; ...
- json string 与object 之间的转化
1.将json string转化成object 1: public static T GetObjectFromJson<T>(string jsonString) 2: { 3: Dat ...
- perl malformed JSON string, neither tag, array, object, number, string or atom, at character offset
[root@wx03 ~]# cat a17.pl use JSON qw/encode_json decode_json/ ; use Encode; my $data = [ { 'name' = ...
- Jackson将json string转为Object,org.json读取json数组
从json文件读取json string或者自定义json string,将其转为object.下面采用的object为map,根据map读取json的某个数据,可以读取第一级的数据name,后来发现 ...
- Convert List<Entity> to Json String.
public static string ToJson(this object obj, string datetimeformats) { var timeConverter = new I ...
- 解决 Jackson反序列化 Unexpected token ... , expected VALUE_STRING: need JSON String that contains type id (for subtype of ...)
首先检查是否是 objectMapper.enableDefaultTyping(); 的受害者.优先考虑删除该配置. 使用Jackson把数组的json字符串反序列化为List时候报了个JsonMa ...
- You're trying to decode an invalid JSON String JSON返回有解析问题
SpringMVC架构的web程序,通常用map返回消息在浏览器中显示,但是实际中报下列错误“”You're trying to decode an invalid JSON String“返回的字符 ...
- How to remove null value in json string
Hi I'm using the below class Public List<string> name; Public List<string> midname; Once ...
- FastJSON 简介及其Map/JSON/String 互转
在日志解析,前后端数据传输交互中,经常会遇到 String 与 map.json.xml 等格式相互转换与解析的场景,其中 json 基本成为了跨语言.跨前后端的事实上的标准数据交互格式.应该来说各个 ...
随机推荐
- iOS核心动画之蒙版
应用场景 想让一些古卷文字慢慢渐变成背景色,而不是一个突兀的边界 layer的边框不是圆角,而是有星形框架的图片 方法 设置mask属性.这个属性也是一个layer属性,但只有alpha属性有效果.即 ...
- JavaScript中setInterval的用法总结
setInterval动作的作用是在播放动画的时,每隔一定时间就调用函数,方法或对象.可以使用本动作更新来自数据库的变量或更新时间显示. setInterval动作的语法格式如下:setInterva ...
- Python自动发送HTML测试报告
在我们做自动化测试的时候,执行完所有的测试用例,我们是希望马上得到结果的,那么我们不可能一直盯着去看,这个时候就需要引入邮件功能 1.首先我们使用一个python的第三方发邮件的库 yagmail g ...
- leetcode-830-Positions of Large Groups
题目描述: In a string S of lowercase letters, these letters form consecutive groups of the same characte ...
- Vs.net 常用命令行
下面的是从 devenv /? 看到的 用法: devenv [解决方案文件 | 项目文件 | 任意文件.扩展名] [开关] devenv 的第一个参数通常是一个解决方案文件或项目文件. 如果 ...
- IIS服务器环境下某路径下所有PHP接口无法运行报500.19错误
IIS服务器环境下某路径(文件夹)下所有PHP接口无法运行报500.19错误 环境:IIS8.5 + php7.2.1 错误描述:某目录下(如 d:\web\A)所有php接口文档运行错误,接口测试工 ...
- js对函数参数的封装
对函数参数的封装 一个原始函数有n个参数,用wrap对函数进行封装,生成一个新的函数,当给它传入参数数量为n的时候,将执行原始函数,否则不执行 //函数封装 function wrap(func){ ...
- AHB协议
AHB2 支持多个Bus Master,例如有三个Master,有四个slave,但是同时只有一个Mater可以拿到Bus的访问权.所以,总线的使用权就需要Master去申请,也就需要一个仲裁器(Ar ...
- spring cloud知识点
eureka注册中心(zookeeper,eureka) 也要集群,可以相互注册,网状结构.后面很多高可用的服务都是用这种方式.Eureka的客户端缓存技术 spring boot actuator ...
- 解决C#中dynamic类型作为泛型参数的反射问题
C#中dynamic类型作为泛型参数传递过去后,反射出来的对象类型是object,我用老外的这篇博文中的代码跑起来,得出的结果是:Flying using a Object map (a map),将 ...