CSharp · Console
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class Program
{
public class Users
{
public string username { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string email { get; set; }
}
public class RootUsers
{
public string status { get; set; }
public List<Users> data { get; set; }
}
public static void Main()
{
dynamic usercollectionWrapper = new
{
add = new RootUsers()
{
status = "success",
data = new List<Users>
{
new Users()
{
username= "alan", firstName= "Alan", lastName= "Johnson", email= "[email protected]"
},
new Users()
{
username= "allison", firstName= "Allison", lastName= "House", email= "[email protected]"
},
new Users()
{
username= "ryan", firstName= "Ryan", lastName= "Carson", email= "[email protected]"
}
}
}
};
var output = JsonConvert.SerializeObject(usercollectionWrapper);
Console.Write(output);
}
}