package com.bluedot.commons.utils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class JSONUtils
{
	public static boolean isValidJSON(String test)
	{
	    try 
	    {
	        new JSONObject(test);
	    } 
	    catch(JSONException ex) 
	    {
	        try 
	        {
	            new JSONArray(test);
	        } 
	        catch(JSONException ex1) 
	        {
	            return false;
	        }
	    }
	    return true;
	}
	
	public static JSONObject merge(JSONObject Obj1, JSONObject Obj2){
		if (Obj1==null && Obj2!=null)
			return new JSONObject(Obj2, JSONObject.getNames(Obj2));
		
		if (Obj1!=null && Obj2==null)
			return new JSONObject(Obj1, JSONObject.getNames(Obj1));
		
		if (Obj1==null && Obj2==null)
			return new JSONObject();
		
		JSONObject merged = new JSONObject(Obj1, JSONObject.getNames(Obj1));
		for(String key : JSONObject.getNames(Obj2))
		{
		  merged.put(key, Obj2.get(key));
		}
		return merged;
	}
}

@@ -797,24 +797,114 @@
 %09JSONObject 
+merged;%0A%09%09%0A%09%09if (JSONObject.getNames(Obj1)==null)%0A%09%09%09merged = new JSONObject();%0A%09%09else%0A%09%09%09
 merged = new
@@ -949,16 +949,19 @@
 Obj1));%0A
+%09%09%0A
 %09%09for(St

fix en merge method