Skip to content

Commit

Permalink
Merge branch 'hotfix/3.3.1' into release/3.4
Browse files Browse the repository at this point in the history
Conflicts:
	WordPress/build.gradle
  • Loading branch information
maxme committed Nov 14, 2014
2 parents 077c819 + 13e613e commit aaccb70
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.wordpress.android.util.AppLog.T;

import java.util.ArrayList;
import java.util.Iterator;

public class JSONUtil {
private static String QUERY_SEPERATOR=".";
Expand Down Expand Up @@ -231,4 +232,25 @@ public static JSONObject getJSONChild(final JSONObject jsonParent, final String
}
return jsonChild;
}

// Returns a copy of the passed JSONObject
@SuppressWarnings("unchecked")
public static JSONObject copyJSONObject(JSONObject object) {
JSONObject objectCopy = new JSONObject();

if (object == null) return objectCopy;

Iterator<String> iterator = object.keys();
while (iterator.hasNext()) {
try {
String key = iterator.next();
Object value = object.get(key);
objectCopy.put(key, value);
} catch (JSONException e) {
AppLog.e(T.UTILS, e);
}
}

return objectCopy;
}
}

0 comments on commit aaccb70

Please sign in to comment.