File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -385,7 +385,23 @@ private string BuildPowerShellParameterArguments(object parameters)
385385 if ( parameters is JsonElement jsonElement )
386386 {
387387 m_Logger . LogDebug ( "Parameters is a JsonElement, type: {Type}" , jsonElement . ValueKind ) ;
388- json = jsonElement . GetRawText ( ) ;
388+
389+ // If JsonElement is a string, it's a JSON string that needs to be unwrapped
390+ if ( jsonElement . ValueKind == JsonValueKind . String )
391+ {
392+ json = jsonElement . GetString ( ) ?? "{}" ;
393+ m_Logger . LogDebug ( "Unwrapped JSON string from JsonElement: {Json}" , json ) ;
394+ }
395+ else if ( jsonElement . ValueKind == JsonValueKind . Object )
396+ {
397+ json = jsonElement . GetRawText ( ) ;
398+ m_Logger . LogDebug ( "Got JSON object from JsonElement: {Json}" , json ) ;
399+ }
400+ else
401+ {
402+ m_Logger . LogWarning ( "JsonElement is not an object or string, type: {Type}" , jsonElement . ValueKind ) ;
403+ return string . Empty ;
404+ }
389405 }
390406 else if ( parameters is string jsonString )
391407 {
You can’t perform that action at this time.
0 commit comments