问题描述
我正在从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"
它将显示一个巨大的消息框,但未找到确定按钮,但没有滚动条。这是因为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)
}
失败,因为它显示的整个内容太大而无法容纳我的屏幕。没有滚动条,我无法按下“确定”按钮。 我看到的选项是显示json块或添加滚动条。 我没有找到向System.Windows.MessageBox添加滚动条的选项。知道如何完成这项工作吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)