title: Finding differences in .JSON files using Powershell Compare-Object, problems with square bracket values
body: <p>I am trying to compare two .json files using</p>
  <pre><code># Compare two files 
  $BLF = (Get-Content -Path C:\Users\...\Documents\Android1.json)
  $CLF =  (Get-Content -Path C:\Users\...\Documents\Android2.json)
  
  $aUnsorted = Compare-Object -ReferenceObject $BLF -DifferenceObject $CLF -IncludeEqual 
  </code></pre>
  <p>I have written code to compare regular variables such as the below &quot;passcodeBlockSimple&quot;, and register the value in one file vs the other. I would like to do the same with values that are defined inside brackets:</p>
  <pre><code>&quot;variableName&quot;: [ 
                       &quot;99&quot;
                  ]
  </code></pre>
  <p>I have a solution for when the two files have the same value, by adding onto the value until it finds the end-bracket ]. That gives &quot;variableName&quot;: [&quot;99&quot;]. See the variable &quot;roleScopeTagIds&quot; below as an example of such a variable.</p>
  <p>I would like to find the value when they are different, but the output from Compare-Object lists the difference line-by-line. Example below, where I loose the information about the variable &quot;restrictedApps&quot; when it is different in the two files (File1 has value &quot;1&quot; and File2 has Value &quot;2&quot;).</p>
  <pre><code>InputObject                                               SideIndicator
  -----------                                               -------------
  &quot;@odata.type&quot;:  &quot;#microsoft.graph.iosCompliancePolicy&quot;,   ==           
      &quot;roleScopeTagIds&quot;:  [                                 ==           
                              &quot;0&quot;                           ==           
                          ],                                ==           
      &quot;version&quot;:  1,                                        ==           
      &quot;passcodeMinutesOfInactivityBeforeScreenTimeout&quot;:  1, ==           
      &quot;managedEmailProfileRequired&quot;:  false,                ==           
      &quot;restrictedApps&quot;:  [                                  ==           
                         ],                                 ==           
          &quot;passcodeBlockSimple&quot;:  false,                    =&gt;           
                          &quot;2&quot;                               =&gt;           
  &quot;passcodeBlockSimple&quot;:  true,                             &lt;=           
                          &quot;1&quot;                               &lt;= 
  </code></pre>
  <p>The files are, File 1:</p>
  <pre><code>&quot;@odata.type&quot;:  &quot;#microsoft.graph.iosCompliancePolicy&quot;,
      &quot;roleScopeTagIds&quot;:  [
                              &quot;0&quot;
                          ],
      &quot;version&quot;:  1,
      &quot;passcodeBlockSimple&quot;:  true,
      &quot;passcodeMinutesOfInactivityBeforeScreenTimeout&quot;:  1,
      &quot;managedEmailProfileRequired&quot;:  false,
      &quot;restrictedApps&quot;:  [
                              &quot;1&quot;
                         ],
  </code></pre>
  <p>And File 2:</p>
  <pre><code>&quot;@odata.type&quot;:  &quot;#microsoft.graph.iosCompliancePolicy&quot;,
      &quot;roleScopeTagIds&quot;:  [
                              &quot;0&quot;
                          ],
      &quot;version&quot;:  1,
      &quot;passcodeBlockSimple&quot;:  false,
      &quot;passcodeMinutesOfInactivityBeforeScreenTimeout&quot;:  1,
      &quot;managedEmailProfileRequired&quot;:  false,
      &quot;restrictedApps&quot;:  [
                              &quot;2&quot;
                         ],
  </code></pre>
  <p>So my question is: How can i find the value of the variable when they are different, and the Compare-Object result is as above?</p>
  <p>(I have to use the Compare-Object function)</p>