protected override IJsonBoxRecord <T> CreateRecord <T>(string json) { var value = (T)serializer.Deserialize(new StringReader(json), typeof(T)); var result = new JsonBoxRecord <T> { Value = value }; serializer.Populate(new StringReader(json), result); return(result); }
protected override IEnumerable <IJsonBoxRecord <T> > CreateRecords <T>(string json) { using (var document = JsonDocument.Parse(json)) { foreach (var item in document.RootElement.EnumerateArray()) { var record = new JsonBoxRecord <T>(); record.Value = JsonSerializer.Deserialize <T>(item.GetRawText()); if (item.TryGetProperty("_id", out var id)) { record.Id = id.GetString(); } if (item.TryGetProperty("_createdOn", out var createdOn)) { record.CreatedOn = createdOn.GetDateTime(); } if (item.TryGetProperty("_updatedOn", out var updatedOn)) { record.UpdatedOn = updatedOn.GetDateTime(); } yield return(record); } } }