Skip to content

Commit

Permalink
Merge pull request #1519 from PowerShell/vors/json
Browse files Browse the repository at this point in the history
Fix ConvertFrom-Json to handle mutlilines
  • Loading branch information
vors committed Jul 26, 2016
2 parents f45179f + 3240a2d commit 5256938
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -93,6 +93,12 @@ protected override void EndProcessing()
// The first input string does not represent a complete Json Syntax.
// Hence consider the the entire input as a single Json content.
}
#if CORECLR
catch (Newtonsoft.Json.JsonSerializationException)
{
// we use another serializer for CORECLR implementation
}
#endif
if (successfullyConverted)
{
for (int index = 1; index < inputObjectBuffer.Count; index++)
Expand Down
@@ -0,0 +1,16 @@
Describe 'ConvertFrom-Json' {
It 'can convert a single-line object' {
('{"a" : "1"}' | ConvertFrom-Json).a | Should Be 1
}

It 'can convert one string-per-object' {
$json = @('{"a" : "1"}', '{"a" : "x"}') | ConvertFrom-Json
$json.Count | Should Be 2
$json[1].a | Should Be 'x'
}

It 'can convert mutli-line object' {
$json = @('{"a" :', '"x"}') | ConvertFrom-Json
$json.a | Should Be 'x'
}
}

0 comments on commit 5256938

Please sign in to comment.