应用一:
[
{
"ID":"1",
"Name":"jsonName",
"c1": [ { "ProductTypeID": "1098", "ProductTypeName": "时尚男鞋"},{"ProductTypeID": "1099","ProductTypeName": "时尚女鞋" } ],
"c2": [ { "ProductID": "1211", "ProductName": "夏季女鞋"},{"ProductID": "1212","ProductName": "冬季女鞋" } ],
"c3": [ { "ProductID": "1211", "ProductName": "夏季女鞋"}],
"c4": [ { "state": "1"}]
}
]
应用二:
[
{
"ProductTypeID":"1099",
"ProductTypeName":"时尚女鞋",
"SlideData":
[
{"ImgSRC":"images/show-4.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-3.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-2.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-1.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"/images/primg_11.png","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"}
],
"ProTypeData":
[
{"TypeID":"1103","TypeName":"短靴鞋"},
{"TypeID":"1104","TypeName":"高跟鞋"},
{"TypeID":"1105","TypeName":"运动鞋"},
{"TypeID":"1106","TypeName":"板鞋"},
{"TypeID":"1107","TypeName":"懒人鞋"},
{"TypeID":"1108","TypeName":"帆布鞋"},
{"TypeID":"1109","TypeName":"豆豆鞋"},
{"TypeID":"1110","TypeName":"凉鞋"}
],
"ProData":
[
{"ProductName":"异形不锈钢","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/f8d074d9-fcf7-4c99-8472-90e10d6be4a0.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/ffa236e9-fa7f-44ba-84aa-b8c2f8799a43.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"米","Price":"100.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/38776187-d1c4-403c-ab18-e25fb281ce9f.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"异型不锈钢","UnitName":"件","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/dccd6921-a3db-454a-93c2-351c8ea4959a.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"SUS304方矩管拉直纹丝","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/2e8d837d-ed7f-4304-9fdb-7ab2d5f19b31.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"方矩管普通砂光","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/15083434-a054-49be-8ebd-63b5bb926dae.jpg","htmURL":"item.icmmall.com/10000142545.html"}
],
"ShopsData":
[
{"CompanyName":"湘潭云飞电子商务有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.yunfei.yfbiz.com"},
{"CompanyName":"湖南泰达天易重工有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.hntidal.com"},
{"CompanyName":"湘潭县华人堂酒厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""},
{"CompanyName":"湘潭诚远缝纫厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""}
]
},
{
"ProductTypeID":"1100",
"ProductTypeName":"时尚男鞋",
"SlideData":
[
{"ImgSRC":"images/show-4.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-3.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-2.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-1.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"/images/primg_11.png","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"}
],
"ProTypeData":
[
{"TypeID":"1103","TypeName":"短靴鞋"},
{"TypeID":"1104","TypeName":"高跟鞋"},
{"TypeID":"1105","TypeName":"运动鞋"},
{"TypeID":"1106","TypeName":"板鞋"},
{"TypeID":"1107","TypeName":"懒人鞋"},
{"TypeID":"1108","TypeName":"帆布鞋"},
{"TypeID":"1109","TypeName":"豆豆鞋"},
{"TypeID":"1110","TypeName":"凉鞋"}
],
"ProData":
[
{"ProductName":"异形不锈钢","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/f8d074d9-fcf7-4c99-8472-90e10d6be4a0.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/ffa236e9-fa7f-44ba-84aa-b8c2f8799a43.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"米","Price":"100.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/38776187-d1c4-403c-ab18-e25fb281ce9f.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"异型不锈钢","UnitName":"件","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/dccd6921-a3db-454a-93c2-351c8ea4959a.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"SUS304方矩管拉直纹丝","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/2e8d837d-ed7f-4304-9fdb-7ab2d5f19b31.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"方矩管普通砂光","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/15083434-a054-49be-8ebd-63b5bb926dae.jpg","htmURL":"item.icmmall.com/10000142545.html"}
],
"ShopsData":
[
{"CompanyName":"湘潭云飞电子商务有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.yunfei.yfbiz.com"},
{"CompanyName":"湖南泰达天易重工有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.hntidal.com"},
{"CompanyName":"湘潭县华人堂酒厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""},
{"CompanyName":"湘潭诚远缝纫厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""}
]
}
]
拼接实例:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using ICM.Utility.Data;
using BL = ICM.BusinessLogic.Leather;
using MD = ICM.Model.Leather;
namespace ICM.Web.Home.AjaxService
{
/// <summary>
/// SelMallItemData 的摘要说明
/// </summary>
public class SelMallItemData : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string IndustryID = context.Request["industryid"];
string CompanyID = context.Request["companyid"];
string SiteID = context.Request["siteid"];
string LevelID = context.Request["levelid"];
BL.IndustryCompanyProduct ICPBL = new BL.IndustryCompanyProduct();
BL.IndustryCompany ICBL = new BL.IndustryCompany();
//========商品行业大类:1F女鞋========
string artSQL = string.Format(@"select ProductTypeID,ProductTypeName from vw_Mall_Industry_ProductType where CompanyID={0} and IndustryID={1} and IsEnable=1 order by orderid,iptid", CompanyID, IndustryID);
DataTable artData = DbHelperSQL.Query(artSQL).Tables[0];
StringBuilder strJson = new StringBuilder();
strJson.Append("[");
for (int i = 0; i < artData.Rows.Count; i++)
{
strJson.Append("{");
strJson.AppendFormat("\"ProductTypeID\":\"{0}\",", artData.Rows[i]["ProductTypeID"].ToString());
strJson.AppendFormat("\"ProductTypeName\":\"{0}\",", artData.Rows[i]["ProductTypeName"].ToString());
#region 商品行业大类:1F女鞋广告
//========begin 商品行业大类:1F女鞋广告========
string slideSQL = string.Format(@"select top 2 ImgSRC,Atitle,Ahref,Atarget from vw_Mall_SlideURL WHERE IndustryID={0} and ProductTypeID={1} and SiteID={2} and LevelID={3} and CompanyID={4} and IsEnable=1 ORDER BY orderid,ImgID", IndustryID, artData.Rows[i]["ProductTypeID"].ToString(), SiteID, LevelID, CompanyID);
DataTable slideData = DbHelperSQL.Query(slideSQL).Tables[0];
strJson.Append("\"SlideData\":");
strJson.Append("[");
for (int k = 0; k < slideData.Rows.Count; k++)
{
strJson.Append("{");
strJson.AppendFormat("\"ImgSRC\":\"{0}\",", slideData.Rows[k]["ImgSRC"].ToString());
strJson.AppendFormat("\"Atitle\":\"{0}\",", slideData.Rows[k]["Atitle"].ToString());
strJson.AppendFormat("\"Ahref\":\"{0}\",", slideData.Rows[k]["Ahref"].ToString());
strJson.AppendFormat("\"Atarget\":\"{0}\"", slideData.Rows[k]["Atarget"].ToString());
if (k != slideData.Rows.Count - 1)
strJson.Append("},");
else
strJson.Append("}");
}
strJson.Append("],");
//========end 商品行业大类:1F女鞋广告========
#endregion
#region 商品行业大类的小分类:短靴鞋、高跟鞋、运动鞋、板鞋
//========begin 商品行业大类的小分类:短靴鞋、高跟鞋、运动鞋、板鞋========
string protSQL = string.Format(@"SELECT TOP 18 TypeID,TypeName FROM [vw_Mall_Industry_ProductTypeList] WHERE IndustryID={0} and ProductTypeID={1} and IsEnable=1 ORDER BY ProductTypeID,TypeID", IndustryID, artData.Rows[i]["ProductTypeID"].ToString());
DataTable protData = DbHelperSQL.Query(protSQL).Tables[0];
strJson.Append("\"ProTypeData\":");
strJson.Append("[");
for (int k = 0; k < protData.Rows.Count; k++)
{
strJson.Append("{");
strJson.AppendFormat("\"TypeID\":\"{0}\",", protData.Rows[k]["TypeID"].ToString());
strJson.AppendFormat("\"TypeName\":\"{0}\"", protData.Rows[k]["TypeName"].ToString());
if (k != protData.Rows.Count - 1)
strJson.Append("},");
else
strJson.Append("}");
}
strJson.Append("],");
//========end 商品行业大类的小分类:短靴鞋、高跟鞋、运动鞋、板鞋========
#endregion
#region 商品行业大类:1F女鞋商品列表
//========begin 商品行业大类:1F女鞋商品列表========
List<MD.IndustryCompanyProductListView> proData = ICPBL.GetIndustryCompanyProductList("SoldAmount DESC,ProductID DESC", "IndustryID=" + IndustryID + " and ProductTypeID=" + artData.Rows[i]["ProductTypeID"].ToString() + " and IsEnable=1", 6, "ProductID,ProductName,UnitName,CustomerSalePrice,SoldAmount,ImgFileURL,CompanyID,CompanyName");
strJson.Append("\"ProData\":");
strJson.Append("[");
for (int k = 0; k < proData.Count(); k++)
{
strJson.Append("{");
strJson.AppendFormat("\"ProductID\":\"{0}\",", proData[k].ProductID);
strJson.AppendFormat("\"ProductName\":\"{0}\",", proData[k].ProductName);
strJson.AppendFormat("\"UnitName\":\"{0}\",", proData[k].UnitName);
strJson.AppendFormat("\"Price\":\"{0}\",", proData[k].CustomerSalePrice);
strJson.AppendFormat("\"sAmount\":\"{0}\",", proData[k].SoldAmount);
strJson.AppendFormat("\"ImgSRC\":\"{0}\",", proData[k].ImgFileURL);
strJson.AppendFormat("\"CompanyID\":\"{0}\",", proData[k].CompanyID);
strJson.AppendFormat("\"CompanyName\":\"{0}\"", proData[k].CompanyName);
if (k != proData.Count() - 1)
strJson.Append("},");
else
strJson.Append("}");
}
strJson.Append("]");
//========end 商品行业大类:1F女鞋商品列表========
#endregion
#region 商品行业大类:1F女鞋商家排行
//代号:灭鼠行动(2016年9月7日 15:10:32):C_IsEnable、M_Isenable合并成IsEnable
//========begin 商品行业大类:1F女鞋商家排行========
//List<MD.IndustryCompanyView> shopsData = ICBL.GetIndustryCompanyList("CompanyID DESC", "IndustryID=" + IndustryID + " and CompanyID in (select CompanyID from vw_Mall_IndustryCompanyProduct where IndustryID=" + IndustryID + " and ProductTypeID=" + artData.Rows[i]["ProductTypeID"].ToString() + " and IsEnable=1 group by CompanyID) and IsEnable=1", 4);
//strJson.Append("\"ShopsData\":");
//strJson.Append("[");
//for (int k = 0; k < shopsData.Count(); k++)
//{
// strJson.Append("{");
// strJson.AppendFormat("\"CompanyID\":\"{0}\",", shopsData[k].CompanyID);
// strJson.AppendFormat("\"CompanyName\":\"{0}\",", shopsData[k].CompanyName);
// strJson.AppendFormat("\"ImgSRC\":\"{0}\"", shopsData[k].LogoURL.Replace("\\", "/"));
// if (k != shopsData.Count() - 1)
// strJson.Append("},");
// else
// strJson.Append("}");
//}
//strJson.Append("]");
//========end 商品行业大类:1F女鞋商家排行========
#endregion
if (i != artData.Rows.Count - 1)
strJson.Append("},");
else
strJson.Append("}");
}
strJson.Append("]");
context.Response.Write(strJson.ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
/*
* json格式如下
[
{
"ProductTypeID":"1099",
"ProductTypeName":"时尚女鞋",
"SlideData":
[
{"ImgSRC":"images/show-4.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-3.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-2.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-1.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"/images/primg_11.png","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"}
],
"ProTypeData":
[
{"TypeID":"1103","TypeName":"短靴鞋"},
{"TypeID":"1104","TypeName":"高跟鞋"},
{"TypeID":"1105","TypeName":"运动鞋"},
{"TypeID":"1106","TypeName":"板鞋"},
{"TypeID":"1107","TypeName":"懒人鞋"},
{"TypeID":"1108","TypeName":"帆布鞋"},
{"TypeID":"1109","TypeName":"豆豆鞋"},
{"TypeID":"1110","TypeName":"凉鞋"}
],
"ProData":
[
{"ProductName":"异形不锈钢","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/f8d074d9-fcf7-4c99-8472-90e10d6be4a0.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/ffa236e9-fa7f-44ba-84aa-b8c2f8799a43.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"米","Price":"100.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/38776187-d1c4-403c-ab18-e25fb281ce9f.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"异型不锈钢","UnitName":"件","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/dccd6921-a3db-454a-93c2-351c8ea4959a.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"SUS304方矩管拉直纹丝","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/2e8d837d-ed7f-4304-9fdb-7ab2d5f19b31.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"方矩管普通砂光","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/15083434-a054-49be-8ebd-63b5bb926dae.jpg","htmURL":"item.icmmall.com/10000142545.html"}
],
"ShopsData":
[
{"CompanyName":"湘潭云飞电子商务有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.yunfei.yfbiz.com"},
{"CompanyName":"湖南泰达天易重工有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.hntidal.com"},
{"CompanyName":"湘潭县华人堂酒厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""},
{"CompanyName":"湘潭诚远缝纫厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""}
]
},
{
"ProductTypeID":"1100",
"ProductTypeName":"时尚男鞋",
"SlideData":
[
{"ImgSRC":"images/show-4.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-3.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-2.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"images/show-1.jpg","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"},
{"ImgSRC":"/images/primg_11.png","Atitle":"","Ahref":"item.icmmall.com/100011537.html","Atarget":"_blank"}
],
"ProTypeData":
[
{"TypeID":"1103","TypeName":"短靴鞋"},
{"TypeID":"1104","TypeName":"高跟鞋"},
{"TypeID":"1105","TypeName":"运动鞋"},
{"TypeID":"1106","TypeName":"板鞋"},
{"TypeID":"1107","TypeName":"懒人鞋"},
{"TypeID":"1108","TypeName":"帆布鞋"},
{"TypeID":"1109","TypeName":"豆豆鞋"},
{"TypeID":"1110","TypeName":"凉鞋"}
],
"ProData":
[
{"ProductName":"异形不锈钢","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/f8d074d9-fcf7-4c99-8472-90e10d6be4a0.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"千克","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/122/152/201404/ffa236e9-fa7f-44ba-84aa-b8c2f8799a43.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"精密钢管","UnitName":"米","Price":"100.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/38776187-d1c4-403c-ab18-e25fb281ce9f.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"异型不锈钢","UnitName":"件","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/dccd6921-a3db-454a-93c2-351c8ea4959a.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"SUS304方矩管拉直纹丝","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/2e8d837d-ed7f-4304-9fdb-7ab2d5f19b31.jpg","htmURL":"item.icmmall.com/10000142545.html"},
{"ProductName":"方矩管普通砂光","UnitName":"米","Price":"0.00000","sAmount":"0","ImgSRC":"/Upload_Files/123/153/201404/15083434-a054-49be-8ebd-63b5bb926dae.jpg","htmURL":"item.icmmall.com/10000142545.html"}
],
"ShopsData":
[
{"CompanyName":"湘潭云飞电子商务有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.yunfei.yfbiz.com"},
{"CompanyName":"湖南泰达天易重工有限公司","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":"www.hntidal.com"},
{"CompanyName":"湘潭县华人堂酒厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""},
{"CompanyName":"湘潭诚远缝纫厂","ImgSRC":"/Upload_Files/1/3/201601/bb36d628-fff2-4b61-a582-1d1586aecf15.jpg","HomeURL":""}
]
}
]
*/
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!