Here is my Json File:
{
\"models\":{},
\"path\":[
{
\"path\":\"/web-profiles\",
\"operations\":[
{
Don't know about any build-in functions but you could try this
public boolean cleanJSON(Object arg) throws JSONException{
boolean valueExist = false;
if(arg instanceof String){
String str= (String)arg;
if(!str.equals("")) valueExist = true;
}else if(arg instanceof JSONObject){
JSONObject obj = (JSONObject)arg;
Iterator iter = obj.keys();
ArrayList fields = new ArrayList<>();
while(iter.hasNext()) fields.add(iter.next());
for(String field:fields){
Object value = obj.get(field);
if(cleanJSON(value)) valueExist = true;
else obj.remove(field);
}
}else if(arg instanceof JSONArray){
JSONArray arr = (JSONArray)arg;
for(int i=0;i
That would clean your json object from empty field(it work recursively). So if the JSON looks like this:
"operations":[
{
"nickname":"",
"type":"",
"responseMessages":[]
}]
field "operations" will also removed.
note : JSONArray.remove only work for API 19 above