-
Notifications
You must be signed in to change notification settings - Fork 8.2k
PowerShell data/hashtable format conversion cmdlets #11300
Copy link
Copy link
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Summary of the new feature/enhancement
Today, it's hard to manipulate PowerShell PSD1/hashtable syntax. Import-PowerShellDataFile provides some options, but it only goes one way, requires a file, and doesn't work with all files ending in psd1 (module manifests allowing "Restricted Language Mode", so having things that ordinary data syntax does not allow).
To make the PowerShell data syntax a first class citizen within PowerShell, I think we would need:
ConvertTo-andConvertFrom-cmdlets- Efficient and consistent [de]serialisation for hashtables, pscustomobjects and arbitrary objects in the usual way
- Support for the extended restricted language mode syntaxes enabled by switches
- An API available to do this without a cmdlet. One place this would help is with the
ModuleSpecificationToString()implementation, which today hand writes psd1 hashtable format.
Proposed technical implementation details (optional)
I have a small prototype here, but I propose the following:
ConvertTo-PsdandConvertFrom-Psdbeing the cmdlets- Following the standard JSON cmdlet conventions, with
DepthandCompressor similar parameters Having a switch for enabling restricted language mode parsing (which will require the full PowerShell parser), perhapsNow that I understand this better, I don't think it fits well with this proposal; restricted language mode parsing is specific to module manifests and doesn't reflect broader usage of PSD format-WithFullParsingor similar
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime