From 14dab9870b65c1b64282e14729c77638604f8e36 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 17 Jun 2014 15:44:06 -0500 Subject: [PATCH] Instantiate psobject directly --- library/windows/assemble.ps1 | 2 +- library/windows/async_wrapper.ps1 | 2 +- library/windows/command.ps1 | 2 +- library/windows/copy.ps1 | 2 +- library/windows/file.ps1 | 2 +- library/windows/ping.ps1 | 2 +- library/windows/slurp.ps1 | 4 ++-- library/windows/stat.ps1 | 6 +++--- library/windows/win_ping | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/windows/assemble.ps1 b/library/windows/assemble.ps1 index 77385b56100..dc95d1b9f53 100644 --- a/library/windows/assemble.ps1 +++ b/library/windows/assemble.ps1 @@ -8,6 +8,6 @@ If ($args.Length -gt 0) $data = 'FIXME'; -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name fixme -Value $data; echo $result | ConvertTo-Json; diff --git a/library/windows/async_wrapper.ps1 b/library/windows/async_wrapper.ps1 index 77385b56100..dc95d1b9f53 100644 --- a/library/windows/async_wrapper.ps1 +++ b/library/windows/async_wrapper.ps1 @@ -8,6 +8,6 @@ If ($args.Length -gt 0) $data = 'FIXME'; -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name fixme -Value $data; echo $result | ConvertTo-Json; diff --git a/library/windows/command.ps1 b/library/windows/command.ps1 index 77385b56100..dc95d1b9f53 100644 --- a/library/windows/command.ps1 +++ b/library/windows/command.ps1 @@ -8,6 +8,6 @@ If ($args.Length -gt 0) $data = 'FIXME'; -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name fixme -Value $data; echo $result | ConvertTo-Json; diff --git a/library/windows/copy.ps1 b/library/windows/copy.ps1 index 77385b56100..dc95d1b9f53 100644 --- a/library/windows/copy.ps1 +++ b/library/windows/copy.ps1 @@ -8,6 +8,6 @@ If ($args.Length -gt 0) $data = 'FIXME'; -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name fixme -Value $data; echo $result | ConvertTo-Json; diff --git a/library/windows/file.ps1 b/library/windows/file.ps1 index 77385b56100..dc95d1b9f53 100644 --- a/library/windows/file.ps1 +++ b/library/windows/file.ps1 @@ -8,6 +8,6 @@ If ($args.Length -gt 0) $data = 'FIXME'; -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name fixme -Value $data; echo $result | ConvertTo-Json; diff --git a/library/windows/ping.ps1 b/library/windows/ping.ps1 index 02560873f5d..ee46cfd4b86 100644 --- a/library/windows/ping.ps1 +++ b/library/windows/ping.ps1 @@ -12,6 +12,6 @@ If (($params | Get-Member | Select-Object -ExpandProperty Name) -contains 'data' $data = $params.data; } -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name ping -Value $data; echo $result | ConvertTo-Json; diff --git a/library/windows/slurp.ps1 b/library/windows/slurp.ps1 index 93a698491fc..21e912f46ae 100644 --- a/library/windows/slurp.ps1 +++ b/library/windows/slurp.ps1 @@ -1,7 +1,7 @@ #!powershell # WANT_JSON -$params = '{}' | ConvertFrom-Json; +$params = New-Object psobject; If ($args.Length -gt 0) { $params = Get-Content $args[0] | ConvertFrom-Json; @@ -27,7 +27,7 @@ If (-not $src) $bytes = [System.IO.File]::ReadAllBytes($src); $content = [System.Convert]::ToBase64String($bytes); -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name content -Value $content; $result | Add-Member -MemberType NoteProperty -Name encoding -Value 'base64'; echo $result | ConvertTo-Json; diff --git a/library/windows/stat.ps1 b/library/windows/stat.ps1 index f779b2531e3..2e87b12275a 100644 --- a/library/windows/stat.ps1 +++ b/library/windows/stat.ps1 @@ -1,7 +1,7 @@ #!powershell # WANT_JSON -$params = '{}' | ConvertFrom-Json; +$params = New-Object psobject; If ($args.Length -gt 0) { $params = Get-Content $args[0] | ConvertFrom-Json; @@ -19,7 +19,7 @@ If (($params | Get-Member | Select-Object -ExpandProperty Name) -contains 'get_m $get_md5 = $params.get_md5; } -$stat = '{}' | ConvertFrom-Json; +$stat = New-Object psobject; If (Test-Path $path) { $stat | Add-Member -MemberType NoteProperty -Name exists -Value $TRUE; @@ -45,7 +45,7 @@ If ($get_md5 -and $stat.exists -and -not $stat.isdir) $stat | Add-Member -MemberType NoteProperty -Name md5 -Value $path_md5; } -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name stat -Value $stat; $result | Add-Member -MemberType NoteProperty -Name changed -Value $FALSE; echo $result | ConvertTo-Json; diff --git a/library/windows/win_ping b/library/windows/win_ping index f64134454db..8eba171d0ea 100644 --- a/library/windows/win_ping +++ b/library/windows/win_ping @@ -12,7 +12,7 @@ If (($params | Get-Member | Select-Object -ExpandProperty Name) -contains 'data' $data = $params.data; } -$result = '{}' | ConvertFrom-Json; +$result = New-Object psobject; $result | Add-Member -MemberType NoteProperty -Name ping -Value $data; echo $result | ConvertTo-Json;