A Powershell module that converts JSON to Powershell classes. JSON can be supplied as a string, a file that will be read or a URL that will be downloaded.
Available in the Powershell Gallery
Convert JSON to Powershell classes. JSON can be supplied as a string, a file that will be read or a URL that will be downloaded.
Optionally create functions showing example usage.
Optionally write an output file.
Optionally copy the output to clipboard.
Install-Module JsonToPowershellClass
Import-Module JsonToPowershellClass
Convert-JsonToPowershellClass
Convert a JSON file to Powershell classes including usage examples and copy the output to clipboard.
Convert-JsonToPowershellClass -JsonFile 'C:\Temp\a-json-file.json' -CopyToClipboard -IncludeExamples
Download JSON from a URL, convert to Powershell classes using 'TestyMcTestFace' as the root class, include usage examples, copy to clipboard and write a ps1 file to the file system
Convert-JsonToPowershellClass -Url 'https://dummyjson.com/products' -IncludeExamples -CopyToClipboard -OutputFile 'C:\Users\rob\Downloads\sample_new3.ps1' -RootObjectClassName TestyMcTestyFace
dotnet build [Github clone/download directory]\ps-json-to-powershell-class\src\PsJsonToPowershellClass\PsJsonToPowershellClass.csproj
Remove any existing installation in this directory, create a new module directory and copy all the built files.
Remove-Item "C:\Users\[User]\Documents\PowerShell\Modules\JsonToPowershellClass" -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path 'C:\Users\[User]\Documents\PowerShell\Modules\JsonToPowershellClass' -ItemType Directory
Get-ChildItem -Path "[Github clone/download directory]\ps-json-to-powershell-class\src\PsJsonToPowershellClass\bin\Debug\net6.0\" | Copy-Item -Destination "C:\Users\[User]\Documents\PowerShell\Modules\JsonToPowershellClass" -Recurse
Please raise an issue if you find a bug or want to request a new feature, or create a pull request to contribute.