Witam,
Otóż chciałbym utworzyć Jsona takiego jak poniżej ale nie wiem jak utworzyć w nim tablicę:
{
"Subject": "API API API",
"Body": {
"ContentType": "HTML",
"Content": "I think it will meet our requirements!"
},
"Start": {
"DateTime": "2016-05-17T18:00:00",
"TimeZone": "Pacific Standard Time"
},
"End": {
"DateTime": "2016-05-17T19:00:00",
"TimeZone": "Pacific Standard Time"
},
"Attendees": [
{
"EmailAddress": {
"Address": "jon.new@office.pl",
"Name": "Janet Schorr"
},
"Type": "Required"
}
]
}
Utworzyłem model :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace DNSAP.API.Models
{
public class _Event
{
public _EmailAddress EmailAddressl;
public string Subject;
public _Body Body;
public _Date Start;
public _Date End;
public _EmailAddress EmailAddress;
}
public class _Body
{
public string ContentType = "HTML";
public string Content;
}
public class _Date
{
public string DateTime;
public string TimeZone = "Pacific Standard Time";
}
public class _EmailAddress
{
public string Address;
public string Name;
}
public class _Type
{
public string Type = "Required";
}
}
Oraz kontrolkę :
public object AddEvent()
{
_Event Event = new _Event()
{
Subject = "",
Body = new _Body() { Content = "HEJO HEJO" },
Start = new _Date() { DateTime = "2016-05-17T18:00:00" },
End = new _Date() { DateTime = "2016-05-17T18:30:00" },
EmailAddressl = new _EmailAddress() { Address = "", Name = "" },
};
return 0;
}
Tutaj mam problem z utworzeniem
"Attendees": [
{
"EmailAddress": {
"Address": "jon.new@office.pl",
"Name": "Janet Schorr"
},
"Type": "Required"
}
]
}
Nie za bardzo wiem jak mam upchać dwa obiekty do list/tablicy.
Czy ktoś może robił coś podobnego ? Lub wie jak to zrobić.
Z góry dziękuje za pomoc.