我有四张桌子:
1)tblcategory - 此表包含所有顶级和子类别
2)tblcatmapping-此表给出了类别mapping.Means哪个类别位于哪个类别
3)tblitem - 此表包含所有菜单项
4)tblitemmapping - 此表包含映射详细信息。可以查看哪些项目属于哪个类别。
tblcategory快照:
tblcatmapping snapshot:
tblitem snapshot
tblitemmapping snapshot:
现在我想以json格式将整个数据发送到Android应用程序。我准备了一个粗略的json样本,我想在其中发送数据。
Json数据样本
[
{
"CATID": "10001",
"CATNAME": "food",
"CATTYPE": "top",
"CATDESC": "contains different types of food",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 11-41-29-food.jpg",
"CATSUBCAT": [
{
"CATID": "10002",
"CATNAME": "veg",
"CATTYPE": "sub",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [
{
"CATID": "10004",
"CATNAME": "nort-indian",
"CATTYPE": "sub",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [],
"CATITEM": [
{
"ITEMID": "20002",
"ITEMNAME": "dosa",
"ITEMTYPE": "item",
"ITEMDESC": "contains different dosa",
"ITEMIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg"
},
{
"ITEMID": "20003",
"ITEMNAME": "idli",
"ITEMTYPE": "item",
"ITEMDESC": "contains different idli",
"ITEMIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg"
}
]
},
{
"CATID": "10005",
"CATNAME": "south-indian",
"CATTYPE": "sub",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [],
"CATITEM": []
}
],
"CATITEM": []
},
{
"CATID": "10003",
"CATNAME": "non-veg",
"CATTYPE": "sub",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [
{
"CATID": "10004",
"CATNAME": "nort-indian",
"CATTYPE": "sub",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [],
"CATITEM": []
},
{
"CATID": "10005",
"CATNAME": "south-indian",
"CATTYPE": "sub",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [],
"CATITEM": []
}
],
"CATITEM": []
}
],
"CATITEM": []
},
{
"CATID": "10006",
"CATNAME": "beverages",
"CATTYPE": "top",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [
{
"CATID": "10007",
"CATNAME": "alcholic-drinks",
"CATTYPE": "top",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [],
"CATITEM": []
},
{
"CATID": "10008",
"CATNAME": "non-alcholic-drinks",
"CATTYPE": "top",
"CATDESC": "contains different drinks",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg",
"CATSUBCAT": [],
"CATITEM": []
}
],
"CATTITEM": []
},
{
"CATID": "10009",
"CATNAME": "fast food",
"CATTYPE": "top",
"CATDESC": "contains various fast foods",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-22-08-fastfood1.jpg",
"CATSUBCAT": [],
"CATITEM": [
{
"ITEMID": "20002",
"ITEMNAME": "dosa",
"ITEMTYPE": "item",
"ITEMDESC": "contains different dosa",
"ITEMIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg"
},
{
"ITEMID": "20003",
"ITEMNAME": "idli",
"ITEMTYPE": "item",
"ITEMDESC": "contains different idli",
"ITEMIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\09-09-2013 12-15-19-beverages.jpeg"
}
]
},
{
"CATID": "10015",
"CATNAME": "test",
"CATTYPE": "top",
"CATDESC": "contains test categories",
"CATIMGPATH": "Z:\\TFS workspace\\DineGenie - Dev\\DineGenie - Dev\\Filestore\\category\\19-09-2013 15-46-19-southindian2.png",
"CATSUBCAT": [],
"CATITEM": []
}
]
我也可以考虑其他格式。我的主要动机是发送所有类别和项目数据,并使用tblcatmapping和tblitemmapping描述的适当关系。
答案 0 :(得分:0)
如果我理解你的问题是正确的,你想看看你的JSON对应的C#会是什么样的,如果是这样的话:
public class RootObject
{
public string CATID { get; set; }
public string CATNAME { get; set; }
public string CATTYPE { get; set; }
public string CATDESC { get; set; }
public string CATIMGPATH { get; set; }
public List<object> CATSUBCAT { get; set; }
public List<object> CATITEM { get; set; }
public List<object> CATTITEM { get; set; }
}
请务必尝试:http://json2csharp.com/