title: What is the JSON Patch format to remove an element from an array?
body: <p>I have the following JSON document, from which I want to remove the &quot;roleId2&quot; element from the &quot;roles&quot; field's array value:</p>
  <pre><code>{
    &quot;id&quot; : 12345,
    &quot;firstName&quot;: &quot;SomeFirstName&quot;,
    &quot;lastName&quot;: &quot;SomeLastName&quot;,
    &quot;roles&quot;:[&quot;roleId1&quot;, &quot;roleId2&quot;, &quot;roleId3&quot;]
  }
  </code></pre>
  <p>How can I write a JSON Patch document to remove that element? Is the following expression valid?</p>
  <pre><code>{&quot;op&quot;: &quot;remove&quot;, &quot;path&quot;:&quot;/roles&quot;, &quot;value&quot;: &quot;roleId2&quot;}
  </code></pre>
  <p>Or, should it look like this (because the &quot;roles&quot; value in the document is an array)?</p>
  <pre><code>{&quot;op&quot;: &quot;remove&quot;, &quot;path&quot;:&quot;/roles&quot;, &quot;value&quot;: [&quot;roleId2&quot;]}
  </code></pre>
  <p>From reading <a href="https://www.rfc-editor.org/rfc/rfc6902#page-10" rel="noreferrer">RFC 6902</a>, it is not clear to me which—if either—is correct. The RFC mentions the following behavior, but I'm not sure if it's relevant here.</p>
  <blockquote>
  <p>If removing an element from an array, any elements above the
  specified index are shifted one position to the left.</p>
  </blockquote>