I am try to covert a c# object to json but am getting json obj in this way
"{\"PkUserId\":1,\"CubicalName\":\"21547\"}"
System.Web.Script.Serialization.JavaScriptSerializer jSearializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
string list = jSearializer.Serialize(genricobj);
public class UserProfile
{
[DataMember]
public int PkUserId { set; get; }
[DataMember]
public string CubicalName { get; set; }
}
the problem is the above json is not a correct json format.
List loginInfolist=new List();
if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
loginInfoDC = new UserProfile();
loginInfoDC.PkUserId = Convert.ToInt32(dr["pkUserId"]);
loginInfoDC.CubicalName = Convert.ToString(dr["CubicalName"]);
loginInfolist.add(loginInfoDC);
}
}
i want to know how to serialise to json and how to differentiate it with list index
say list[0] json and the lit[1]json
meant all the serialised json of the list will be in same json obj how to differentiate