<%@ Page Language="C#" %>
<%@ Import Namespace="Newtonsoft.Json" %>
<!DOCTYPE html>
<script runat="server">
public string json;
protected void Page_Load(object sender, EventArgs e)
{
List<uye> u = new List<uye>();
List<uye.alver> a = new List<uye.alver>();
a.Add(new uye.alver("Pazartesi", "10:35","17:00"));
a.Add(new uye.alver("Salı", "09:00","16:35"));
List<uye.alver> b = new List<uye.alver>();
b.Add(new uye.alver("Pazartesi", "11:25","19:30"));
b.Add(new uye.alver("Salı", "12:25","20:30"));
u.Add(new uye("fatih", "topcu", a));
u.Add(new uye("miraç", "topcu", b));
json = JsonConvert.SerializeObject(u, Formatting.Indented);
}
public class uye
{
public string adi;
public string soyadi;
public List<alver> girisCikis;
public uye(string a, string s, List<alver> avg)
{
adi = a;
soyadi = s;
girisCikis = avg;
}
public class alver
{
public string gun;
public string giris;
public string cikis;
public alver(string v1, string v2, string v3)
{
gun = v1;
giris = v2;
cikis = v3;
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<script>
<%=json %></script>
<%=json %>
</body>
</html>
sayfa çıktısı aşağıdaki şekilde olacaktır
| <script> | |
| [ | |
| { | |
| "adi": "fatih", | |
| "soyadi": "topcu", | |
| "girisCikis": [ | |
| { | |
| "gun": "Pazartesi", | |
| "giris": "10:35", | |
| "cikis": "17:00" | |
| }, | |
| { | |
| "gun": "Salı", | |
| "giris": "09:00", | |
| "cikis": "16:35" | |
| } | |
| ] | |
| }, | |
| { | |
| "adi": "miraç", | |
| "soyadi": "topcu", | |
| "girisCikis": [ | |
| { | |
| "gun": "Pazartesi", | |
| "giris": "11:25", | |
| "cikis": "19:30" | |
| }, | |
| { | |
| "gun": "Salı", | |
| "giris": "12:25", | |
| "cikis": "20:30" | |
| } | |
| ] | |
| } | |
| ]</script> |
Hiç yorum yok:
Yorum Gönder