Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ConvertTo-JSON: Nested Object of type Newtonsoft.Json.Linq.JObject not converted to Json properly #4996

Copy link
Copy link
@amanarneja

Description

@amanarneja
Issue body actions

Used the following Azure PS commands and discovered that a Nested JObject is just being converted to an Array instead of an Object.
In the repro steps the type of $result.Outputs.mediaServiceFullInfo.Value is of type Newtonsoft.Json.Linq.JObject as you can see in the final JSON Value doesn't have the Key and Values and has a Square Bracket around it.
$result.Outputs.mediaServiceFullInfo.Value.ToString() does output the Json Snippet under Value correctly.

Steps to reproduce

[Update] : Simplified repro steps in the comments.

$resourceGroupName = 'ExampleResourceGroup'
New-AzureRmResourceGroup -Name $resourceGroupName -Location 'Central US' -Verbose -Force
$result = New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName $resourceGroupName `
  -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/media-service-output-primary-key/azuredeploy.json

$result.Outputs | ConvertTo-Json

Expected behavior

{
"mediaServiceFullInfo": {
"type": "Object",
"value": {
"primaryAuthEndpoint": "https://wamsprodglobal001acs.accesscontrol.windows.net/",
"secondaryAuthEndpoint": "https://wamsprodglobal002acs.accesscontrol.windows.net/",
"scope": "urn:windowsazuremediaservices"
}
},
"mediaServicePrimaryKey": {
"type": "String",
}
}

Actual behavior

`{
"mediaServiceFullInfo": {
"Type": "Object",
"Value": [
"https://wamsprodglobal001acs.accesscontrol.windows.net/",
"https://wamsprodglobal002acs.accesscontrol.windows.net/",
"urn:windowsazuremediaservices"
]
},
"mediaServicePrimaryKey": {
"Type": "String",
}
}

Environment data

PS C:\WINDOWS\system32> $PSVersionTable

Name Value


PSVersion 5.1.16299.15
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.15
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.