I've create a .NET web service with JSON. but the result didn't show as array. how to make the JSON result into array in my web service?
here is my web service code:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public String GetReport()
{
ModelReport.Report report = new ModelReport.Report();
string connectionString = ConfigurationManager.ConnectionStrings["ConnWf"].ConnectionString;
using (SqlConnection connection = new SqlConnection(connectionString))
{
string sql = "select type, sum(OrderQty) as total from tbl_weeklyflash_ID where type <> 'NULL' group by type";
connection.Open();
SqlCommand command = new SqlCommand(sql, connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
report.type = reader["type"].ToString();
report.total = reader["total"].ToString();
}
}
MemoryStream stream = new MemoryStream();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ModelReport.Report));
serializer.WriteObject(stream, report);
stream.Position = 0;
StreamReader streamReader = new StreamReader(stream);
return streamReader.ReadToEnd();
}