Created
April 18, 2014 17:54
-
-
Save Iristyle/11056390 to your computer and use it in GitHub Desktop.
PS2 JSON Polyfill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertFrom-JsonString | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true, ValueFromPipeline=$true)] | |
[string] | |
$Json | |
) | |
Add-Type -AssemblyName System.Web.Extensions | |
$jsSerializer = New-Object Web.Script.Serialization.JavaScriptSerializer | |
return $jsSerializer.DeserializeObject($json) | |
} | |
function ConvertTo-JsonString | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true, ValueFromPipeline=$true)] | |
[AllowNull()] | |
[PSObject] | |
$InputObject | |
) | |
Add-Type -AssemblyName System.Web.Extensions | |
$jsSerializer = New-Object Web.Script.Serialization.JavaScriptSerializer | |
return $jsSerializer.Serialize($InputObject) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment