-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hello,
your addon powershell is great...
he take me many day to discover this nightmare dealing with escaped Unicode sequences.
can you have tips ?
I try this after micrsoft copilot help me:
= [System.Text.RegularExpressions.Regex]::Unescape($jqoutputcontent)
full code to correct your class powershell (by copilot)
class MyJsonClass
{
[object] $MyJsonData = $null
MyJsonClass([string]$JsonFilePath)
{
# Lire le contenu du fichier JSON avec encodage UTF-8
$jsonContent = Get-Content -Path $JsonFilePath -Raw -Encoding UTF8
$this.MyJsonData = $jsonContent | ConvertFrom-Json
}
[string] GetJsonValue()
{
$jsonString = $this.MyJsonData | ConvertTo-Json -Depth 99
$decodedJsonString = [MyJsonClass]::DecodeUnicodeString($jsonString)
return $decodedJsonString
}
[string] static DecodeUnicodeString([string]$input)
{
return [System.Text.RegularExpressions.Regex]::Unescape($input)
}
}
# Utilisation de la classe
$instance = [MyJsonClass]::new("...\Prtg_to_alerta\rawjson-fileRAW.json")
Write-Output $instance.GetJsonValue()
I join sample file json: utf8
rawjson-file.json
thanks for your help
Metadata
Metadata
Assignees
Labels
No labels
