Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PowerShell,序列化为JSON时出错_Json_Powershell - Fatal编程技术网

PowerShell,序列化为JSON时出错

PowerShell,序列化为JSON时出错,json,powershell,Json,Powershell,我在JSON文件中包含以下内容: { "edit_errorcantloadgoogleaddress": "Impossible de récupérer les propositions d\u0027adresses \"{code}\"." } 按以下方式分析并保存它: $a = Get-Content -Raw -Path D:\test.json | ConvertFrom-Json $a | ConvertTo-Json 我得到了以下不解析的结果: 有人知道如何解决

我在JSON文件中包含以下内容:

{ 
    "edit_errorcantloadgoogleaddress":  "Impossible de récupérer les propositions d\u0027adresses \"{code}\"."
}
按以下方式分析并保存它:

$a = Get-Content -Raw -Path D:\test.json | ConvertFrom-Json
$a | ConvertTo-Json
我得到了以下不解析的结果:


有人知道如何解决这个问题吗?

正如@user2871239所提到的,这是一个与版本相关的问题,我升级到了PS 4.0来解决它。

断线
code
正在丢弃它……好吧,那么我应该如何“逃避”它呢?因为用javascript(parse/stringify)加载/保存初始文件不会产生任何问题。使用
-Compress
可以解决问题,但与我对具有可读JSON文件的期望不符。
-Compress
似乎是一种可行的方法。您的期望是什么?最终的JSON文件必须是可读的。压缩时不是那么容易。我刚刚尝试了你的PowerShell,我得到的输出与输入相同-没有额外的换行符。我正在Windows 7上运行.NET 4.6上的PowerShell 4.0。你在跑什么?
{
    "edit_errorcantloadgoogleaddress":  "Impossible de récupérer les propositions d\u0027adresses \"{
                                            code
                                        }\"."
}