Bug 776027 - Move intent handling to IntentHelper. r=wesj
This commit is contained in:
@@ -9,7 +9,16 @@ import java.util.UUID;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class JSONUtils {
|
||||
private static final String LOGTAG = "GeckoJSONUtils";
|
||||
|
||||
private JSONUtils() {}
|
||||
|
||||
public static UUID getUUID(String name, JSONObject json) {
|
||||
@@ -25,4 +34,21 @@ public final class JSONUtils {
|
||||
throw new IllegalArgumentException(name + "=" + uuidString, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject bundleToJSON(Bundle bundle) {
|
||||
if (bundle == null || bundle.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
for (String key : bundle.keySet()) {
|
||||
try {
|
||||
json.put(key, bundle.get(key));
|
||||
} catch (JSONException e) {
|
||||
Log.w(LOGTAG, "Error building JSON response.", e);
|
||||
}
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user