From a21438ef59fd25e2860b04260fb07cdc948a6069 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 15 Oct 2024 21:13:42 -0700 Subject: [PATCH] feat: Export-4bitJSON ( Fixes #80 ) --- Commands/Export-4BitJSON.ps1 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Commands/Export-4BitJSON.ps1 diff --git a/Commands/Export-4BitJSON.ps1 b/Commands/Export-4BitJSON.ps1 new file mode 100644 index 0000000000..817aad2c43 --- /dev/null +++ b/Commands/Export-4BitJSON.ps1 @@ -0,0 +1,29 @@ +function Export-4BitJSON { + <# + .SYNOPSIS + Exports 4bitcss data to a json file + .DESCRIPTION + Exports 4bitcss data to a json file. + + This is simple wrapper of ConvertTo-Json, with support for writing to a file. + #> + param( + # The input object to convert to JSON + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject, + + # The output path. + [string] + $OutputPath + ) + + process { + $asJson = ConvertTo-Json -Compress -InputObject $InputObject + if ($OutputPath) { + New-Item -Path $outputPath -Force -Value $asJson + } else { + $asJson + } + } +} \ No newline at end of file