Instantiate psobject directly

This commit is contained in:
Matt Martz 2014-06-17 15:44:06 -05:00
parent ac6ccb77cc
commit 14dab9870b
9 changed files with 12 additions and 12 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;