mon web-service renvoie les données json comme indiqué ci-dessous mais je voulais comme dans 2nd CodeSnipts. mon web-service et classe comme indiqué ci-dessous.Convertir le format Json Réponse du webservice
{ "ShowID": 10107,
"StartTime": "3:00 PM",
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg"
},{ "ShowID": 115,
"StartTime": "6:00 PM",
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg"
},{ "ShowID": 110,
"StartTime": "9:00 PM",
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg"
}
mais je veux que
{
"MovieID": 13,
"Movie": "Bhaag Milkha Bhaag ",
"Screen": "CDC SCreen2",
"MediaPath": "bmb1_568962.jpg",
"ShowInfo": [
{
"ShowID": 10107,
"StartTime": "3:00 PM"
},
{
"ShowID": 115,
"StartTime": "6:00 PM"
},
{
"ShowID": 110,
"StartTime": "9:00 PM"
}
]
}
mon code C# pour Webservice comme
[WebMethod]
public string NowShowingGetList(DateTime ShowDate)
{
HomeController obj = new HomeController();
JavaScriptSerializer js = new JavaScriptSerializer();
string retJSON = js.Serialize(obj.NowShowingGetList(ShowDate));
return retJSON;
}
classe
public class NowShowingInfo
{
public int ShowID { get; set; }
public string StartTime { get; set; }
public int MovieID { get; set; }
public string Movie { get; set; }
public string Screen { get; set; }
public string MediaPath { get; set; }
}
ici obj.NowShowingGetList(ShowDate)
retour Liste Merci d'avance.
Vous devez créer un nouveau nom de classe ShowInfo et annonce d Array ou Liste dans le NowShowingInfo. La classe ShowInfo contiendra les propriétés name: ShowId et StartTime –
Vous devez créer un nouveau nom de classe ShowInfo et ajouter un tableau ou une liste dans le NowShowingInfo. La classe ShowInfo con – manoj