defaults.json cannot be processed by Windows PowerShell's ConvertFrom-JSON #20632

Closed
opened 2026-01-31 07:19:39 +00:00 by claunia · 4 comments
Owner

Originally created by @sba923 on GitHub (Oct 6, 2023).

Windows Terminal version

1.19.2309.25002

Windows build number

10.0.22621.2361.amd64fre.ni_release.220506-1250

Other Software

Windows PowerShell 5.1.22621.1778

Steps to reproduce

gc 'C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.19.2682.0_x64__8wekyb3d8bbwe\defaults.json' | ConvertFrom-JSON

Expected Behavior

defaultProfile              : {61c54bbd-c2c6-5271-96e7-009a87ff44bf}
initialCols                 : 120
initialRows                 : 30
launchMode                  : default
alwaysOnTop                 : False
copyOnSelect                : False
copyFormatting              : True
trimBlockSelection          : True
trimPaste                   : True
wordDelimiters              :  /\()"'-.,:;<>~!@#$%^&*|+=[]{}~?│
alwaysShowTabs              : True
showTabsInTitlebar          : True
showTerminalTitleInTitlebar : True
tabWidthMode                : equal
tabSwitcherMode             : inOrder
showAdminShield             : True
confirmCloseAllTabs         : True
startOnUserLogin            : False
theme                       : dark
snapToGridOnResize          : True
disableAnimations           : False
startupActions              :
focusFollowMouse            : False
minimizeToNotificationArea  : False
alwaysShowNotificationIcon  : False
profiles                    : {@{guid={61c54bbd-c2c6-5271-96e7-009a87ff44bf}; name=Windows PowerShell;
                              commandline=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe;
                              icon=ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png;
                              colorScheme=Campbell; antialiasingMode=grayscale; closeOnExit=automatic;
                              cursorShape=bar; fontFace=Cascadia Mono; fontSize=12; hidden=False; historySize=9001;
                              padding=8, 8, 8, 8; snapOnInput=True; altGrAliasing=True;
                              startingDirectory=%USERPROFILE%; useAcrylic=False},
                              @{guid={0caa0dad-35be-5f56-a8ff-afceeeaa6101}; name=Command Prompt;
                              commandline=%SystemRoot%\System32\cmd.exe;
                              icon=ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png;
                              colorScheme=Campbell; antialiasingMode=grayscale; closeOnExit=automatic;
                              cursorShape=bar; fontFace=Cascadia Mono; fontSize=12; hidden=False; historySize=9001;
                              padding=8, 8, 8, 8; snapOnInput=True; altGrAliasing=True;
                              startingDirectory=%USERPROFILE%; useAcrylic=False}}
schemes                     : {@{name=Campbell; foreground=#CCCCCC; background=#0C0C0C; cursorColor=#FFFFFF;
                              black=#0C0C0C; red=#C50F1F; green=#13A10E; yellow=#C19C00; blue=#0037DA; purple=#881798;
                              cyan=#3A96DD; white=#CCCCCC; brightBlack=#767676; brightRed=#E74856;
                              brightGreen=#16C60C; brightYellow=#F9F1A5; brightBlue=#3B78FF; brightPurple=#B4009E;
                              brightCyan=#61D6D6; brightWhite=#F2F2F2}, @{name=Campbell Powershell;
                              foreground=#CCCCCC; background=#012456; cursorColor=#FFFFFF; black=#0C0C0C; red=#C50F1F;
                              green=#13A10E; yellow=#C19C00; blue=#0037DA; purple=#881798; cyan=#3A96DD;
                              white=#CCCCCC; brightBlack=#767676; brightRed=#E74856; brightGreen=#16C60C;
                              brightYellow=#F9F1A5; brightBlue=#3B78FF; brightPurple=#B4009E; brightCyan=#61D6D6;
                              brightWhite=#F2F2F2}, @{name=Vintage; foreground=#C0C0C0; background=#000000;
                              cursorColor=#FFFFFF; black=#000000; red=#800000; green=#008000; yellow=#808000;
                              blue=#000080; purple=#800080; cyan=#008080; white=#C0C0C0; brightBlack=#808080;
                              brightRed=#FF0000; brightGreen=#00FF00; brightYellow=#FFFF00; brightBlue=#0000FF;
                              brightPurple=#FF00FF; brightCyan=#00FFFF; brightWhite=#FFFFFF}, @{name=One Half Dark;
                              foreground=#DCDFE4; background=#282C34; cursorColor=#FFFFFF; black=#282C34; red=#E06C75;
                              green=#98C379; yellow=#E5C07B; blue=#61AFEF; purple=#C678DD; cyan=#56B6C2;
                              white=#DCDFE4; brightBlack=#5A6374; brightRed=#E06C75; brightGreen=#98C379;
                              brightYellow=#E5C07B; brightBlue=#61AFEF; brightPurple=#C678DD; brightCyan=#56B6C2;
                              brightWhite=#DCDFE4}…}
themes                      : {@{name=light; window=; tab=; tabRow=}, @{name=dark; window=; tab=; tabRow=},
                              @{name=system; window=; tab=}, @{name=legacyDark; tab=; window=}…}
actions                     : {@{command=closeWindow; keys=alt+f4}, @{command=toggleFullscreen; keys=alt+enter},
                              @{command=toggleFullscreen; keys=f11}, @{command=toggleFocusMode}…}

Actual Behavior

ConvertFrom-JSON : Invalid JSON primitive: .
At line:1 char:116
+ ... view_1.19.2682.0_x64__8wekyb3d8bbwe\defaults.json' | ConvertFrom-JSON
+                                                          ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
Originally created by @sba923 on GitHub (Oct 6, 2023). ### Windows Terminal version 1.19.2309.25002 ### Windows build number 10.0.22621.2361.amd64fre.ni_release.220506-1250 ### Other Software Windows PowerShell 5.1.22621.1778 ### Steps to reproduce ```powershell gc 'C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_1.19.2682.0_x64__8wekyb3d8bbwe\defaults.json' | ConvertFrom-JSON ``` ### Expected Behavior ```` defaultProfile : {61c54bbd-c2c6-5271-96e7-009a87ff44bf} initialCols : 120 initialRows : 30 launchMode : default alwaysOnTop : False copyOnSelect : False copyFormatting : True trimBlockSelection : True trimPaste : True wordDelimiters : /\()"'-.,:;<>~!@#$%^&*|+=[]{}~?│ alwaysShowTabs : True showTabsInTitlebar : True showTerminalTitleInTitlebar : True tabWidthMode : equal tabSwitcherMode : inOrder showAdminShield : True confirmCloseAllTabs : True startOnUserLogin : False theme : dark snapToGridOnResize : True disableAnimations : False startupActions : focusFollowMouse : False minimizeToNotificationArea : False alwaysShowNotificationIcon : False profiles : {@{guid={61c54bbd-c2c6-5271-96e7-009a87ff44bf}; name=Windows PowerShell; commandline=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe; icon=ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png; colorScheme=Campbell; antialiasingMode=grayscale; closeOnExit=automatic; cursorShape=bar; fontFace=Cascadia Mono; fontSize=12; hidden=False; historySize=9001; padding=8, 8, 8, 8; snapOnInput=True; altGrAliasing=True; startingDirectory=%USERPROFILE%; useAcrylic=False}, @{guid={0caa0dad-35be-5f56-a8ff-afceeeaa6101}; name=Command Prompt; commandline=%SystemRoot%\System32\cmd.exe; icon=ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png; colorScheme=Campbell; antialiasingMode=grayscale; closeOnExit=automatic; cursorShape=bar; fontFace=Cascadia Mono; fontSize=12; hidden=False; historySize=9001; padding=8, 8, 8, 8; snapOnInput=True; altGrAliasing=True; startingDirectory=%USERPROFILE%; useAcrylic=False}} schemes : {@{name=Campbell; foreground=#CCCCCC; background=#0C0C0C; cursorColor=#FFFFFF; black=#0C0C0C; red=#C50F1F; green=#13A10E; yellow=#C19C00; blue=#0037DA; purple=#881798; cyan=#3A96DD; white=#CCCCCC; brightBlack=#767676; brightRed=#E74856; brightGreen=#16C60C; brightYellow=#F9F1A5; brightBlue=#3B78FF; brightPurple=#B4009E; brightCyan=#61D6D6; brightWhite=#F2F2F2}, @{name=Campbell Powershell; foreground=#CCCCCC; background=#012456; cursorColor=#FFFFFF; black=#0C0C0C; red=#C50F1F; green=#13A10E; yellow=#C19C00; blue=#0037DA; purple=#881798; cyan=#3A96DD; white=#CCCCCC; brightBlack=#767676; brightRed=#E74856; brightGreen=#16C60C; brightYellow=#F9F1A5; brightBlue=#3B78FF; brightPurple=#B4009E; brightCyan=#61D6D6; brightWhite=#F2F2F2}, @{name=Vintage; foreground=#C0C0C0; background=#000000; cursorColor=#FFFFFF; black=#000000; red=#800000; green=#008000; yellow=#808000; blue=#000080; purple=#800080; cyan=#008080; white=#C0C0C0; brightBlack=#808080; brightRed=#FF0000; brightGreen=#00FF00; brightYellow=#FFFF00; brightBlue=#0000FF; brightPurple=#FF00FF; brightCyan=#00FFFF; brightWhite=#FFFFFF}, @{name=One Half Dark; foreground=#DCDFE4; background=#282C34; cursorColor=#FFFFFF; black=#282C34; red=#E06C75; green=#98C379; yellow=#E5C07B; blue=#61AFEF; purple=#C678DD; cyan=#56B6C2; white=#DCDFE4; brightBlack=#5A6374; brightRed=#E06C75; brightGreen=#98C379; brightYellow=#E5C07B; brightBlue=#61AFEF; brightPurple=#C678DD; brightCyan=#56B6C2; brightWhite=#DCDFE4}…} themes : {@{name=light; window=; tab=; tabRow=}, @{name=dark; window=; tab=; tabRow=}, @{name=system; window=; tab=}, @{name=legacyDark; tab=; window=}…} actions : {@{command=closeWindow; keys=alt+f4}, @{command=toggleFullscreen; keys=alt+enter}, @{command=toggleFullscreen; keys=f11}, @{command=toggleFocusMode}…} ```` ### Actual Behavior ```` ConvertFrom-JSON : Invalid JSON primitive: . At line:1 char:116 + ... view_1.19.2682.0_x64__8wekyb3d8bbwe\defaults.json' | ConvertFrom-JSON + ~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand ````
Author
Owner

@lhecker commented on GitHub (Oct 6, 2023):

We use JSONC (JSON with comments) for our settings and PowerShell added support for that only in PowerShell 7. Is there any reason you need this to work in PowerShell 5?

@lhecker commented on GitHub (Oct 6, 2023): We use JSONC (JSON with comments) for our settings and PowerShell added support for that only in PowerShell 7. Is there any reason you need this to work in PowerShell 5?
Author
Owner

@sba923 commented on GitHub (Oct 6, 2023):

After https://github.com/microsoft/terminal/issues/15963 was closed I started to write a Get-WindowsTerminalShortcut.ps1 script to extract the current Windows Terminal keybindings.

And I do my best to keep backwards compatibility with Windows PowerShell in all my scripts.

Sure, the keybindings are global, not per-profile, so I can just run the script from PowerShell 7...

@sba923 commented on GitHub (Oct 6, 2023): After https://github.com/microsoft/terminal/issues/15963 was closed I started to write a `Get-WindowsTerminalShortcut.ps1` script to extract the current Windows Terminal keybindings. And I do my best to keep backwards compatibility with Windows PowerShell in all my scripts. Sure, the keybindings are global, not per-profile, so I can just run the script from PowerShell 7...
Author
Owner

@zadjii-msft commented on GitHub (Oct 11, 2023):

Yea, this sounds like something we're not about to change any time soon. PowerShell 7 is the officially supported version of PowerShell. I don't know enough about their servicing model to know if they would even consider backporting support for jsonc to the 5.x version. I'd guess not.

@zadjii-msft commented on GitHub (Oct 11, 2023): Yea, this sounds like something we're not about to change any time soon. PowerShell 7 is the officially supported version of PowerShell. I don't know enough about their servicing model to know if they would even consider backporting support for jsonc to the 5.x version. I'd guess not.
Author
Owner

@sba923 commented on GitHub (Oct 11, 2023):

I'll probably think about borrowing from https://github.com/StartAutomating/TerminalVelocity/blob/main/Get-WTProfile.ps1.

@sba923 commented on GitHub (Oct 11, 2023): I'll probably think about borrowing from https://github.com/StartAutomating/TerminalVelocity/blob/main/Get-WTProfile.ps1.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20632