i want create a custom json data from the mssql 2008 results so that my iPhone could consume it.
i can consume json websites like this without a problem:
json link
the format could look like this:
Place: New York
Hotel: Widget Hotel
Telephone: 0305525253
which format should i return to consume it on the iPhone? an array a string, dictionary? i don’t know
EDIT: here is my code:
namespace WebService1
{
public class LandHelper
{
internal static string[] Land()
{
List<string> landObject = new List<string>();
using (SqlConnection con = new SqlConnection(@"Data Source=Localhost\SQLEXPRESS;Initial Catalog=BOOK-IT-V2;Integrated Security=true;"))
using (SqlCommand cmd = new SqlCommand(@"SELECT BEZEICHNUNG FROM LAND", con))
{
con.Open();
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
if (rdr["BEZEICHNUNG"] != DBNull.Value)
{
landObject.Add(rdr["BEZEICHNUNG"].ToString());
}
}
}
}
return landObject.ToArray();
}
}
}
i tried this but i don’t know how to add a key to the values i get from the database.
i think it would be easier when i create a custom json format .
Just Return a List like
You can return easy a JSON-FORMAT