2

My $obj variable has two properties, nodes and rules. There is no issue with nodes, but here is the problem with rules:

# Here, I'm converting the specific "rules" property instead of the entire object.
# This is correct and the output should be exactly like this

$obj.rules | ConvertTo-Json

{
"name":  "wildcard",
"description":  "match all request",
"include":  {
                "path":  [
                             "*"
                         ]
            }
} 

However, converting the entire object to JSON results in this:

$obj | ConvertTo-Json
{
"nodes":  {
                 #Nodes are displayed correctly here
          },          
"rules":  [
              {
                  "name":  "wildcard",
                  "description":  "match all request",
                  "include":  "@{path=System.Object[]}"
              }
          ]

Look at the last line, I don't know why this is happening. I'm trying to convert the entire object and export it to a JSON file.

I've even tried looking into converting the two object properties separately and merging them into one variable in order to export the JSON file but haven't figured that out yet.

Any idea on why this is happening? Workarounds?

Please advise!

DivZ
  • 678
  • 12
  • 20

0 Answers0