Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

ConvertTo-Json in PowerShell output changes when object is nested one level deeper

Please note the output of the following block of code on PowerShell -

        $Attendees = @(
            @{
            "EmailAddress" = [pscustomobject]@{
                "Address" = "[email protected]";
                "Name" = "test1";
             };
             "Type" = "Required";
            };
        );
        
        ConvertTo-Json $Attendees;
        $PSObject = @{ "Attendees" = $Attendees; };
        ConvertTo-Json $PSObject;

Output -

Code snippet output

Note how "EmailAddress" changes from object to a string. How can I prevent this from happening?

question from:https://stackoverflow.com/questions/65623780/convertto-json-in-powershell-output-changes-when-object-is-nested-one-level-deep

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...