public GetObject ( ) : System.Json.JsonObject | ||
return | System.Json.JsonObject |
public static Person Create(JsonValue personValue) { Person person = new Person(); JsonObject jsonData = personValue.GetObject(); int id; IJsonValue idValue; if (jsonData.TryGetValue("id", out idValue)) { if (idValue.ValueType == JsonValueType.String) { if (int.TryParse(jsonData.GetNamedString("id"), out id)) { person.Id = id; } } else if (idValue.ValueType == JsonValueType.Number) { if (int.TryParse(jsonData.GetNamedNumber("id").ToString(), out id)) { person.Id = id; } } } person.FirstName = jsonData.GetNamedString("firstName"); person.LastName = jsonData.GetNamedString("lastName"); return person; }
private static OrderItem Create(JsonValue value) { OrderItem item = new OrderItem(); JsonObject data = value.GetObject(); int id; double price, quantity; item.Name = data.GetNamedString("name"); item.Description = data.GetNamedString("description"); if (int.TryParse(data.GetNamedNumber("id").ToString(), out id)) { item.Id = id; } if (double.TryParse(data.GetNamedNumber("price").ToString(), out price)) { item.Price = price; } if (double.TryParse(data.GetNamedNumber("quantity").ToString(), out quantity)) { item.Quantity = quantity; } return item; }
public static Order Create(JsonValue orderJson) { Order order = new Order(); JsonObject data = orderJson.GetObject(); int id; if (int.TryParse(data.GetNamedNumber("id").ToString(), out id)) { order.Id = id; } order.Items = OrderItemFactory.CreateList(data.GetNamedValue("items")); order.Customer = PersonFactory.Create(data.GetNamedValue("customer")); return order; }
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; }
internal static ThemeUniqueItem FromJson(JsonValue jsonValue) { if (jsonValue == null) { return null; }; ThemeUniqueItem item = new ThemeUniqueItem(); item.Caption = jsonValue.GetObject()["caption"].GetStringEx(); item.Style = ServerStyle.FromJson(jsonValue.GetObject()["style"].GetObjectEx()); item.Unique = jsonValue.GetObject()["unique"].GetStringEx(); item.Visible = jsonValue.GetObject()["visible"].GetBooleanEx(); return item; }
private static GradeInfo GetGradeInfo(JsonValue gradeValue) { JsonObject gradeObject = gradeValue.GetObject(); GradeInfo info = new GradeInfo(); info.CourseCode = gradeObject.GetNamedString("course_code"); info.CourseTitle = gradeObject.GetNamedString("course_title"); info.CourseType = gradeObject.GetNamedString("course_type"); info.CourseOption = gradeObject.GetNamedString("option").ToUpper(); info.Credits = (ushort)gradeObject.GetNamedNumber("credits"); info.Grade = gradeObject.GetNamedString("grade")[0]; info.AssignExamDate(gradeObject.GetNamedString("exam_held")); if (info.CourseOption == "NIL") info.CourseOption = ""; return info; }