Skip to content

Commit

Permalink
Fix for Json arrays with only one child object
Browse files Browse the repository at this point in the history
Would previously not return the child objects in a one item array.
  • Loading branch information
dnewsholme committed May 22, 2018
1 parent e8c1980 commit 60c4dda
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ConvertTo-FlatObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,14 @@
continue
}

#Check for arrays
$IsArray = @($ChildValue).count -gt 1
#Check for arrays by checking object type (this is a fix for arrays with 1 object) otherwise check the count of objects
if (($ChildValue.GetType()).basetype.Name -eq "Array") {
$IsArray = $true
}
else {
$IsArray = @($ChildValue).count -gt 1
}

$count = 0

#Set up the path to this node and the data...
Expand Down Expand Up @@ -384,4 +390,4 @@
Recurse-Object -Object $Object -Output $( New-Object -TypeName PSObject )
}
}
}
}

0 comments on commit 60c4dda

Please sign in to comment.