【发布时间】:2021-11-19 12:14:21
【问题描述】:
我有以下代码:
$getvalue= 'true&replicaSet=users-shard-0&authSource=adsfsdfin&readPreference=neasrest&maxPoolSize=50&minPoolSize=10&maxIdleTimeMS=60'
$getvalue = $getvalue -replace '&','&'
$pathToJson = 'C:\1\test.json'
$a = Get-content -Path $pathToJson | ConvertFrom-Json
$a.connectionStrings.serverstring=$getvalue
$a | ConvertTo-Json | Set-content $pathToJson -ErrorAction SilentlyContinue
我得到以下结果:
true\u0026replicaSet=users-shard-0\u0026authSource=adsfsdfin\u0026readPreference=neasrest\u0026maxPoolSize=50\u0026minPoolSize=10\u0026maxIdleTimeMS=60
有&符号转换成\u0026。如何防止隐蔽值。 你可以参考这个question
我需要 & 登录 json 文件而不是 \u0026
【问题讨论】:
-
..但是.. answer given to the question you reference 不够好?
标签: json powershell