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- and ConvertFrom- 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
ModuleSpecification ToString() 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-Psd and ConvertFrom-Psd being the cmdlets
- Following the standard JSON cmdlet conventions, with
Depth and Compress or similar parameters
Having a switch for enabling restricted language mode parsing (which will require the full PowerShell parser), perhaps -WithFullParsing or similar Now 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
Summary of the new feature/enhancement
Today, it's hard to manipulate PowerShell PSD1/hashtable syntax.
Import-PowerShellDataFileprovides 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-cmdletsModuleSpecificationToString()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 cmdletsDepthandCompressor similar parametersHaving 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