Private/ScrubJsonUnicodeSymbols.ps1
function ScrubJsonUnicodeSymbols { [CmdletBinding()] Param ( [Parameter(Mandatory=$True)] [string]$JsonFilePath ) try { $FullJsonFilePath = (Resolve-Path $JsonFilePath).Path } catch { Write-Error $_ $global:FunctionResult = "1" return } <# '\u2018' = "'" '\u2019' = "'" '\u201A' = ',' '\u201B' = "'" '\u201C' = '"' '\u201D' = '"' #> $UnicodeSymbolHT = $(Get-Module HTMLToJson).Invoke({$UnicodeSymbolConversion}) $JsonFileContent = Get-Content $FullJsonFilePath $UnicodeHTPairs = $UnicodeSymbolHT.GetEnumerator() foreach ($KVPair in $UnicodeHTPairs) { switch ($KVPair.Name) { {$_ -match '\\u2018|\\u2019|\\u201A|\\u201B'} {$JsonFileContent = $JsonFileContent -replace [regex]::Escape($KVPair.Name),$KVPair.Value} {$_ -match '\\u201C|\\u201D'} {$JsonFileContent = $JsonFileContent -replace [regex]::Escape($KVPair.Name),$('\' + $KVPair.Value)} } } $JsonFileContent } |