title: How to Add New Array Index in JSON using JsonPath?
body: <p>I'm trying to add one more index value to the path:</p>
  <p><code>$.data.library.category[2].book</code> using <code>jayway jsonpath</code> in following Json,</p>
  <pre><code> &quot;data&quot;:{
      &quot;library&quot;:{
      &quot;class&quot;:&quot;CRED&quot;,
      &quot;category&quot;:[{
                  &quot;book&quot;:&quot;java 2.0&quot;
              },
              {
                  &quot;book&quot;:&quot;java 3.0&quot;
              }]
      }
  </code></pre>
  <p>but i'm not getting updated response in result json.</p>
  <p>My java code:</p>
  <pre><code>Configuration conf = Configuration.defaultConfiguration().addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL).addOptions(Option.SUPPRESS_EXCEPTIONS);  
  DocumentContext documentContext = JsonPath.using(conf).parse(sampleJson);
  documentContext.set(JsonPath.compile(&quot;$.data.library.category[2].book&quot;), &quot;java 3.0&quot;);
  </code></pre>
  <p>I have checked also with <code>documentContext.add</code>. Nothing works out. Since the array has 0 and 1 index, i can update the value there by JsonPath. But it dont have 2nd index, so not updating. But I need to insert new index in the last of given json as per jsonpath.</p>