From 7904380c8ba35ccd6657e828d88e45a8123ee235 Mon Sep 17 00:00:00 2001 From: Martin Wiethan <47688561+Marterich@users.noreply.github.com> Date: Mon, 15 Jul 2024 03:06:00 +0200 Subject: [PATCH] Fix Compile Errors on PowerShell 5 (#2322) * Fixed Extraction of JSON Object Names * Update Comment to reflect the code Co-authored-by: Mr.k --------- Co-authored-by: Mr.k --- Compile.ps1 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Compile.ps1 b/Compile.ps1 index a8bf570d..e5399475 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -56,12 +56,10 @@ Get-ChildItem .\config | Where-Object {$psitem.extension -eq ".json"} | ForEach- # Replace every XML Special Character so it'll render correctly in final build # Only do so if json files has content to be displayed (for example the applications, tweaks, features json files) - # Some Type Convertion using Casting and Cleaning Up of the convertion result using 'Replace' Method + # Make an Array List containing every name at first level of Json File $jsonAsObject = $json | convertfrom-json - $firstLevelJsonList = ([System.String]$jsonAsObject).split('=;') | ForEach-Object { - $_.Replace('=}','').Replace('@{','').Replace(' ','') - } - + $firstLevelJsonList = [System.Collections.ArrayList]::new() + $jsonAsObject.PSObject.Properties.Name | ForEach-Object {$null = $firstLevelJsonList.Add($_)} # Note: # Avoid using HTML Entity Codes, for example '”' (stands for "Right Double Quotation Mark"), # Use **HTML decimal/hex codes instead**, as using HTML Entity Codes will result in XML parse Error when running the compiled script.