using System; using System.Collections.Generic; using Newtonsoft.Json; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { private void Awake() { var accountJames = new Account { Email = "james@example.com", Active = true, CreatedDate = new DateTime(2013, 1, 20, 0, 0, 0, DateTimeKind.Utc), Roles = new List { "User", "Admin" }, Ve = new Vector3(10, 3, 1) }; var accountOnion = new Account { Email = "onion@example.com", Active = true, CreatedDate = new DateTime(2013, 1, 20, 0, 0, 0, DateTimeKind.Utc), Roles = new List { "User", "Admin" }, Ve = new Vector3(0, 3, 1) }; var setting = new JsonSerializerSettings(); setting.Formatting = Formatting.Indented; setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; var accounts = new List {accountJames, accountOnion}; var json = JsonConvert.SerializeObject(accounts, setting); print(json); } public class Account { public string Email { get; set; } public bool Active { get; set; } public DateTime CreatedDate { get; set; } public IList Roles { get; set; } public Vector3 Ve { get; set; } } }