public static Person Create(string jsonString) { JsonValue json; Person person = new Person(); if (JsonValue.TryParse(jsonString, out json)) { person = PersonFactory.Create(json); } return person; }
public static Person Create(JsonValue personValue) { Person person = new Person(); JsonObject jsonObject = personValue.GetObject(); int? id = jsonObject.GetIntegerValue("id"); if (id.HasValue) { person.Id = id.Value; } person.FirstName = jsonObject.GetStringValue("firstName"); person.LastName = jsonObject.GetStringValue("lastName"); bool? isOnWestCoast = jsonObject.GetBooleanValue("isOnWestCoast"); if (isOnWestCoast.HasValue) { person.IsOnWestCoast = isOnWestCoast.Value; } return person; }