【发布时间】:2014-03-10 14:34:11
【问题描述】:
我正在尝试开发以下格式的 json。
{
"contacts":[
{
"id":"c200",
"name":"Ravi Tamada",
"email":"ravi@gmail.com",
"address":"xx-xx-xxxx,x - street, x - country",
"gender":"male",
"phone":[
{
"Section":"International"
}]
}]
}
使用下面我已经使用了我的程序
public class Cont
{
public string sno { get; set; }
public string name { get; set; }
public string em { get; set; }
public string address { get; set; }
public string gender { get; set; }
// public Phone phone = new Phone();
public List<Phone> phone { get; set; }
// Phone = new Phone();
}
public class Phone
{
public string Section { get; set; }
}
public class RootObject
{
public List<Cont> contacts { get; set; }
}
这里我传递了所有的值,所有的值都来自数据库
ContCollection.Add(new Cont()
{
sno = dr["Cinema"].ToString(),
name = dr["Gallery"].ToString(),
address = dr["star"].ToString(),
gender = dr["video"].ToString(),
em = "",
/how can i use List<Phone> here
});
请大家解释一下
感谢和问候
【问题讨论】:
-
你是如何从数据库中获取数据的,它是当前阅读器上的逗号分隔字段,你是否单独调用?
-
我有单独的 db 方法
-
你之前问题的答案有什么问题?
-
我同意,其他问题的答案对我来说似乎是合理的。
-
以前只有电话对象。但我需要电话是对象数组