gpt4 book ai didi

json - ConvertFrom-Json是否尊重-ErrorAction

转载 作者:行者123 更新时间:2023-12-02 23:24:10 26 4
gpt4 key购买 nike

我正在编写一个需要解析JSON的脚本,并且在某些文件中出现错误。错误的原因是无效的JSON,这很好,但是我希望能够检测到该错误并在脚本中处理它。好像ConvertFrom-Json不支持-ErrorAction。真的吗?我在网上看不到任何东西。

最佳答案

ErrorAction是在PowerShell 2中添加的通用参数

ConvertFrom-JSON MSDN article

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



编辑:这是PowerShell 5和6的 bug logged on the PowerShell GitHub

关于json - ConvertFrom-Json是否尊重-ErrorAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41272128/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com