将JSON对象转换成IList,好用linq
JObject
JToken
JProperty
IList<>
搞得头都大了,记而备忘:
JObject json = .....
JToken[] jps = json["records"][0].ToArray();
List<ItemInfo> cols = json["columns"].ToObject<List<ItemInfo>>();
int len = jps.Length;
int i = 0;
int limit = 2;
StringBuilder sb = new StringBuilder("");
sb.Append(@"<div><table><tr>");
for (int j = 1; j < len; j++)
{
JProperty jp = jps[j] as JProperty;
string displayname = cols.Where(m => (m.Name.CompareTo(jp.Name) == 0)).First().DisplayName;
sb.Append(String.Format(@"<td>{0}:</td><td><input type=""text"" value=""{1}"" name=""{2}""/></td>"
, displayname
, jp.Value
, jp.Name));
i++;
if (i % limit == 0)
{
sb.Append("</tr><tr>");
}
}
if (i % limit != 0)
{
for (i = i % limit; i < limit; i++)
{
sb.Append("<td> </td>");
}
sb.Append("</tr>");
}
else
{
sb.Remove(sb.Length - 4, 4);
}
sb.Append("</table></div>");
将JSON对象转换成IList,好用linq的更多相关文章
- 前台 JSON对象转换成字符串 相互转换 的几种方式
在最近的工作中,使用到JSON进行数据的传递,特别是从前端传递到后台,前台可以直接采用ajax的data函数,按json格式传递,后台Request即可,但有的时候,需要传递多个参数,后台使用requ ...
- json字符串转换成json对象,json对象转换成字符串,值转换成字符串,字符串转成值
一.json相关概念 json,全称为javascript object notation,是一种轻量级的数据交互格式.采用完全独立于语言的文本格式,是一种理想的数据交换格式. 同时,json是jav ...
- JSON对象转换成JSON字符串
1.问题背景 有一个json对象,需要将其转换成json字符串 JSON.stringify(obj) 2.实现源码 <!DOCTYPE html PUBLIC "-//W3C//DT ...
- json字符串转json对象,json对象转换成java对象
@RequestMapping(value = "updateInvestorApplyAccountNo", method = RequestMethod.POST) @Resp ...
- json字符串转成 json对象 json对象转换成java对象
import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject; 依赖包 <dependency> ...
- gson和fastjson将json对象转换成javaBean 简单对照
今天在网上看代码时,发现项目使用了Gson,用于将json字符串转换成javaBean. 以前没使用过Gson,随即,简单入了个们, 想起fastjson也有将json字符串转换成javaBean的A ...
- JSON对象转换成字符串【JSON2.JS】
下载地址 https://github.com/douglascrockford/JSON-js JSON.JS和JSON2.JS的区别 JSON.JS使用的方法名称不同,用的是toJSONStrin ...
- json 字符串转换成对象,对象转换成json字符串
json 字符串转换成对象,对象转换成json字符串 前端: 方法一: parseJSON方法: [注意jquery版本问题] var str = '{"name":&qu ...
- (精华)将json数组和对象转换成List和Map(小龙哥和牛徳鹤的对话)
将java标准的数据结构ArrayList和HashMap转换成json对象和数组很简单 只需要JSONArray.fromObject(obj);或者JSONObject.fromObject(ob ...
随机推荐
- 2.10.2 section元素
section元素 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> & ...
- Linux C动态链接库实现一个插件例子
实现一个简单的计算动态链接库:升级动态链接库后,在不重新编译主程序的情况下,直接生效. lib库: #cat math.c #include <stdio.h> int add(int x ...
- React入门介绍(1)-ReactDOM.render()等基础
React入门介绍-ReactDOM.render()等基础 首先,React是一个用于构建用户界面的Javascript库,但Peact并不是一套完整的MVC或MVVM的框架,它仅涵盖V-view视 ...
- vue 轮播插件使用
<template> <div> <Swiper ref="swiper" v-if="list.length > 0" : ...
- [USACO12MAR] 摩天大楼里的奶牛 Cows in a Skyscraper
题目描述 A little known fact about Bessie and friends is that they love stair climbing races. A better k ...
- jenkins构建项目记录2(tag)
与jenkins构建项目记录1不同的是通过tag拉去对应版本代码 1.先安装创建(git parameter) 2.general设置 name可任意命名,下面源码管理设置时变量会引用到. 3.源码管 ...
- Go:冒泡排序
package main import "fmt" func BubbleSort(arr *[5]int) { fmt.Println("排序前:", *ar ...
- LeetCode(46)Permutations
题目 Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the fo ...
- [bzoj3531][Sdoi2014][旅行] (主席树+树链剖分)
Description S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天面条神教.隐形独角兽教.绝地教都是常见的信仰. ...
- prometheus监控mysql
创建一个用于mysqld_exporter连接到MySQL的用户并赋予所需的权限 mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO '; my ...