Skip to content

Commit

Permalink
Updated to handle various types of arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
MHove89 committed May 4, 2023
1 parent c115ca8 commit cc0a9b5
Showing 1 changed file with 50 additions and 15 deletions.
65 changes: 50 additions & 15 deletions src/Enterspeed/Enterspeed.Migrator/Enterspeed/PagesResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,57 @@ private void CreateArrayType(PageData pageData, JsonProperty jsonProperty, Enter
var arrayOfElements = jsonProperty.Value.EnumerateArray();
foreach (var element in arrayOfElements)
{
if (element.ValueKind == JsonValueKind.Object)
switch (element.ValueKind)
{
var objectOfElement = element.EnumerateObject();
var newArrayItem = new EnterspeedPropertyType()
{
Name = "arrayObject",
Alias = "arrayObject",
Type = JsonValueKind.Object,
Value = objectOfElement
};

// Add arrayitem directly to array property
currentProperty.ChildProperties.Add(newArrayItem);

MapData(pageData, element, newArrayItem);
};
case JsonValueKind.Undefined:
break;
case JsonValueKind.Object:
var objectOfElement = element.EnumerateObject();
var newArrayItem = new EnterspeedPropertyType()
{
Name = "arrayObject",
Alias = "arrayObject",
Type = JsonValueKind.Object,
Value = objectOfElement
};

// Add arrayitem directly to array property
currentProperty.ChildProperties.Add(newArrayItem);
MapData(pageData, element, newArrayItem);
break;
case JsonValueKind.Array:
break;
case JsonValueKind.String:
var stringItem = new EnterspeedPropertyType()
{
Name = "string",
Alias = "string",
Type = JsonValueKind.String,
Value = element.GetString()
};

// Add arrayitem directly to array property
currentProperty.ChildProperties.Add(stringItem);
break;
case JsonValueKind.Number:
var numberItem = new EnterspeedPropertyType()
{
Name = "string",
Alias = "string",
Type = JsonValueKind.String,
Value = element.GetInt32()
};

// Add arrayitem directly to array property
currentProperty.ChildProperties.Add(numberItem);
break;
case JsonValueKind.True:
break;
case JsonValueKind.False:
break;
case JsonValueKind.Null:
break;
}
}

// Ensure that we do not add nested properties to the root level of the properties for the page.
Expand Down

0 comments on commit cc0a9b5

Please sign in to comment.