Reputation: 7605
Part of my class file
namespace Calendar
{
class CalendarModel
{
[JsonProperty("name")]
public string name { get; set; }
In my implementation file, I declared a private variable
private List<CalendarModel> people;
In a method, I am getting my JSON Object with this code
people = JsonConvert.DeserializeObject<List<CalendarModel>>((string)fileContainingJSONObject);
How would I create an Array of people? Then how would I access its members (later)?
Upvotes: 0
Views: 128
Reputation: 2164
Just declare a list of list of CalendarModel
var crowd = new private List<List<CalendarModel>>();
...
people = JsonConvert.DeserializeObject<List<CalendarModel>>((string)fileContainingJSONObject);
crowd.add(people)
To access the properties of the CalendarModel
objects:
crowd[peopleIndex][calendarModelIndex].name
Upvotes: 2