public static Parse ( |
||
model | The parent model of the section. | |
obj | Newtonsoft.Json.Linq.JObject | The instance of JObject to be parsed. |
리턴 |
/// <summary> /// Deserializes the specified <paramref name="json"/> string into an instance of <see cref="GridDataModel"/>. /// </summary> /// <param name="json">The JSON string to be deserialized.</param> /// <param name="propertyTypeAlias">The alias of the property the Grid model is representing.</param> public static GridDataModel Deserialize(string json, string propertyTypeAlias) { // Validate the JSON if (json == null || !json.StartsWith("{") || !json.EndsWith("}")) { return(null); } // Deserialize the JSON JObject obj = JObject.Parse(json); // Parse basic properties GridDataModel model = new GridDataModel(obj) { Raw = json, Name = obj.GetString("name"), PropertyAlias = propertyTypeAlias }; // Parse the sections model.Sections = obj.GetArray("sections", x => GridSection.Parse(model, x)) ?? new GridSection[0]; // Return the model return(model); }
public static GridDataModel Parse(JObject obj) { if (obj == null) { return(null); } return(new GridDataModel(obj) { Raw = obj.ToString(), Name = obj.GetString("name"), Sections = obj.GetArray("sections", x => GridSection.Parse(null, obj)) ?? new GridSection[0] }); }