title: Is there a way to easily upade a JSON node using Jackson's ObjectMapper?
body: <p>Given this JSON read from a file:</p>
  <pre><code>{
      &quot;Book&quot;: &quot;Test&quot;,
      &quot;Subscription&quot;: [{
          &quot;RateIt&quot;: [{
              &quot;Id&quot;: &quot;1234&quot;,
              &quot;Size&quot;: &quot;XL&quot;,
              &quot;RateMe&quot;: [{
                  &quot;id&quot;: &quot;5678&quot;,
                  &quot;Pages&quot;: &quot;&quot;
              }],
              &quot;Test_Demo&quot;: null
          }],
          &quot;DemoID&quot;: &quot;test1111&quot;,
          &quot;subNumber&quot;: &quot;9999&quot;
  
      }],
      &quot;Author_FirstName&quot;: &quot;Test&quot;
  }
  </code></pre>
  <p>I tried to update <code>DemoID</code> field with a different value, this way:</p>
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  JsonNode requestParams = mapper.readTree(new File(&quot;src/test/resources/myFile.json&quot;));
  JsonNode subscriptionPath = requestParams.at(&quot;/Subscription&quot;);
  System.out.println(subscriptionPath ); //value was retrieved OK
  ((ObjectNode) subscriptionPath).put(&quot;DemoID&quot;, &quot;test0000&quot;); //error on this line
  </code></pre>
  <p>But got the exception:</p>
  <pre><code>java.lang.ClassCastException: com.fasterxml.jackson.databind.node.TextNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode
  </code></pre>
  <p>I also tried using the DemoIDpath instead, but got the same exception:</p>
  <pre><code>JsonNode idPath = requestParams.at(&quot;/Subscription/0/DemoID&quot;);//path was found OK
  ((ObjectNode) idPath).put(&quot;DemoID&quot;, &quot;test0000&quot;); // error on this line
  </code></pre>
  <p>What am I doing wrong with the use of <code>ObjectNode</code>?</p>