How to override the 2nd Object JSON with 1st JSON object
<p>I have a situation where I need to override 2nd JSON object value to 1st.</p>

<p>JSON original  :-</p>

<pre><code>{
    "products": {
        "productsApp15": {
            "status": "active",
            "attribute_set": "Apparel",
            "name": "productsApp16",
            "product_type": "product",
            "code": "productsApp16"
        }
    }
}
</code></pre>

<p>My 1st object :-</p>

<pre><code>{
    "productsApp15": {
        "attribute_set": "Apparel",
        "status": "active",
        "name": "productsApp16",
        "product_type": "product",
        "code": "productsApp16"
    }
}
</code></pre>

<p>My 2nd object :-</p>

<pre><code>{
    "attribute_set": "Apparel",
    "status": "active",
    "name": "productsApp16",
    "product_type": "product",
    "code": "try"
}
</code></pre>

<p>If you see the value of key -> <code>code</code> is updated here. I want this change in my real or 1st JSON object so I can pass it to my Payload</p>

<p>My Code:-</p>

<pre><code>    FileReader reader = new FileReader(filePath);

    JSONParser jsonParser = new JSONParser();
    JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);

    JSONObject jsonObject1 = (JSONObject) jsonObject.get("products");
    JSONObject jsonObject2 = (JSONObject)jsonObject1.get("productsApp15");
    String firstName = (String) jsonObject2.get("code").toString();

    System.out.println("The first name is: " + firstName);

    jsonObject2.remove("code");
    jsonObject2.put("code", "try");

    JSONObject jsonObject3 = (JSONObject)jsonObject1.get("productsApp15");
    String firstName2 = (String) jsonObject2.get("code").toString();
    System.out.println("The first name is: " + jsonObject3);

    JSONObject combined = new JSONObject();
    combined.put("Object1", jsonObject1);
    combined.put("Object2", jsonObject3);
    String firstName3 = (String) jsonObject2.get("code").toString();
    System.out.println("The first name is: " + combined);
</code></pre>

<p>My Main objective :- I am reading a file which contain my JSON, As you can see my object is again inside an another object . </p>

<p>I want to update the value and then want to pass it to payload.</p>

<p><strong>But how to get the original JSON structure with updated value?</strong></p>

<p>Is it possible?</p>