有没有办法在消息中拆分PowerShell中的json数据,以便我可以滚动查看

有没有办法在消息中拆分PowerShell中的json数据,以便我可以滚动查看,json,powershell,messagebox,Json,Powershell,Messagebox,我从ReSTapi回调中得到一个json,它看起来像: { "Section1": { "Heading1": [ "Thing1", "Thing2" ] }, "Section2": [ "Thing1", "Thing2" ] } 现在,当我运行带有 Add-Type -Asse

我从ReSTapi回调中得到一个json,它看起来像:

{
  "Section1": {
    "Heading1": [
      "Thing1",
      "Thing2"
    ]
  },
  "Section2": [
    "Thing1",
    "Thing2"
  ]
}
现在,当我运行带有

Add-Type -AssemblyName PresentationCore,PresentationFramework     
        $ButtonType = [System.Windows.MessageBoxButton]::Ok
        $MessageIcon = [System.Windows.MessageBoxImage]::Information
        $MessageBody = "$_"
        $MessageTitle = "JSON"
它会显示一个巨大的消息框,没有找到ok按钮,但没有滚动条。这是因为json包含其中80个部分。我的第一个想法是拆分json或添加一个滚动条。 在$con包含此json的位置拆分:

$con | ConvertTo-Json | ForEach-Object {
        Add-Type -AssemblyName PresentationCore,PresentationFramework     
        $ButtonType = [System.Windows.MessageBoxButton]::Ok
        $MessageIcon = [System.Windows.MessageBoxImage]::Information
        $MessageBody = "$_"
        $MessageTitle = "JSON"

        $Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
        }
失败,因为它显示的整个内容太大,不适合我的屏幕。没有滚动条,我无法点击OK按钮。 我看到的选项是为块显示json块或添加滚动条。
我找不到向System.Windows.MessageBox添加滚动条的选项。你知道我该怎么做吗?

为什么不把它输出到一个文件中,然后用你最喜欢的编辑器打开它?更高级的(比如Notepad++)甚至会在更改时刷新(更不用说对JSON的本机支持)。如果您真的想留在PowerShell中,最方便的选择可能是使用一些Windows窗体代码来生成一个窗口,其中只有一个文本框可以接受输出
MessageBox
实际上只用于发送短消息,无法自定义。