4

I have the following json structure

{  
   "MerchHierarchyEBM":{  
      "DataArea":{  
         "Division":{  
            "UpdatedBy":"SN",
            "Group":{  
               "GroupName":"Womens Fashion*",
               "UpdatedBy":"Data Migration",
               "UpdatedOn":"22-NOV-17",
               "GroupID":"200"
            },
            "DivisionName":"Fashion",
            "UpdatedOn":"22-NOV-17",
            "DivisionID":"2000"
         }
      }
   }
}

and i want to remove the "Group" key and value from the json object using java i tried few things but didn't work following is my code .

JSONObject jsonObjIncomingDatanew =new JSONObject(Result);
jsonObjIncomingDatanew.remove("MerchHierarchyEBM.DataArea.Division.Group");
1

1 Answer 1

6

Try this:

JSONObject jsonObject = new JSONObject(Result);
jsonObject
  .getJSONObject("MerchHierarchyEBM")
  .getJSONObject("DataArea")
  .getJSONObject("Division")
  .remove("Group");

Or if getJSONObject() doesn't work, replace it with getAsJsonObject().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.