Skip to content

Commit

Permalink
Added some extra options for parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Nov 3, 2014
1 parent 63b7b4a commit 6ca26c5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Skybrud.Umbraco.GridData/GridDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
namespace Skybrud.Umbraco.GridData {

public class GridDataModel {

[JsonIgnore]
public string Raw { get; private set; }

[JsonIgnore]
public JObject JObject { get; private set; }

/// <summary>
/// Gets the name of the selected layout.
/// </summary>
Expand Down Expand Up @@ -50,10 +53,20 @@ select control
// Parse the JObject
return new GridDataModel {
Raw = json,
JObject = obj,
Name = obj.GetString("name"),
Sections = obj.GetArray("sections", GridSection.Parse) ?? new GridSection[0]
};

}

public static GridDataModel Parse(JObject obj) {
if (obj == null) return null;
return new GridDataModel {
Raw = obj.ToString(),
Name = obj.GetString("name"),
Sections = obj.GetArray("sections", GridSection.Parse) ?? new GridSection[0]
};

}

}
Expand Down

0 comments on commit 6ca26c5

Please sign in to comment.