title: How Do I overwrite data from a JSONObject using Java?
body: <p>Below I provided a test code that basically I use to check a particular json file (new-info.json) and compares data (assert equals) to confirm whether or not what I wrote is actually reading the file. Right now I'm on a mental road block with my next plan of action which is:</p>
  <ol>
  <li>overwrite the insert time with the current time</li>
  <li>add current time (the value of String new_time) into the JSON Object (foundObj).</li>
  <li>compare the two times to confirm whether or not the code itself is actually reading and comparing the json file and what i wrote or is just looking at only what i wrote.</li>
  </ol>
  <p>Based off of what I wrote and what my 3 plans of actions - what should I do (code wise)?</p>
  <p>inside the json file it's simply something like this</p>
  <pre><code>{
  &quot;user_interface_fields&quot; : {
  &quot;tip_identifier&quot; : {
  &quot;uuid&quot;: &quot;12345678-1234-1234-1234-123456789112&quot;
  }
  &quot;insert_time&quot; : &quot;2020-01-01T00:00:00Z&quot;
  }
  </code></pre>
  <pre><code>@Test
  public void testExampleMessageToJson() throws Throwable {
  log.info(&quot;\n\nTesting persist service [message to json]?\n&quot;);
  
  //Setup
  String rawJson = TestUtils.getResourceMessage(&quot;examples/new-info.json&quot;);
  String tip_identifier_uuid = &quot;12345678-1234-1234-1234-123456789112&quot;;
  
  log.info(&quot;Raw Json:\n():, rawJson); 
  assertTrue(StringUtils.isNotBlank(rawJson));
  
  //Test
  JSONObject foundObj = persistService.messageToJson(rawJson); 
  
  //Verify
  String tip_identifier_time = foundObj.getString(&quot;insert_time&quot;);
  String new_time = new SimpleDateFormat(&quot;yyyy-MM-dd T HH:mm:ss Z&quot;).format(Calendar.getInstance().getTime());
  
  String new_uuid = foundObj.getJSONObject(&quot;user_interface_fields&quot;).getJSONObject(&quot;tip_identifier&quot;).getString(&quot;uuid&quot;);
  assertEquals(tip_identifier_uuid , new_uuid); 
  assertEquals(tip_identifier_time, new_time);
  log.info(&quot;\n\nTesting persist service [message to json] COMPLETE!\n&quot;);
  }
  </code></pre>