using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for Menu
/// </summary>
public class Menu
{
public Menu()
{
//
// TODO: Add constructor logic here
//
}
public int ID { get; set; }
public int ParentMenuID { get; set; }
public string MenuName { get; set; }
public string MenuCode { get; set; }
public string MenuClickURL { get; set; }
}
4、使用的构造JSON数据格式的类(此类不是本人写的,来源于互联网)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Reflection;
using System.Collections;
using System.Data;
using System.Data.Common;
/// <summary>
/// Summary description for FormatToJson
/// </summary>
public class FormatToJson
{
public FormatToJson()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// List转成json
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="jsonName"></param>
/// <param name="list"></param>
/// <returns></returns>
public static string ListToJson<T>(IList<T> list, string jsonName)
{
StringBuilder Json = new StringBuilder();
if (string.IsNullOrEmpty(jsonName))
jsonName = list[0].GetType().Name;
Json.Append("{\"" + jsonName + "\":[");
if (list.Count > 0)
{
for (int i = 0; i < list.Count; i++)
{
T obj = Activator.CreateInstance<T>();
 
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>