Add API to retrieve Java Object from Flipper objects
Summary: There's no existing API on the Flipper objects to get an arbitrary Java object, which we need in an inspector plugin we're building (`getDynamic` requires you to know what you want in the end). Reviewed By: jknoxville Differential Revision: D21223329 fbshipit-source-id: 29e9f8788be404cec44c6ddeb6b56b939b97b766
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7e4682b694
commit
c7a6908093
@@ -67,6 +67,18 @@ public class FlipperArray {
|
||||
return new FlipperArray((JSONArray) o);
|
||||
}
|
||||
|
||||
public Object get(int index) {
|
||||
final Object o = mJson.opt(index);
|
||||
|
||||
if (o instanceof JSONObject) {
|
||||
return new FlipperObject((JSONObject) o);
|
||||
} else if (o instanceof JSONArray) {
|
||||
return new FlipperArray((JSONArray) o);
|
||||
} else {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return mJson.length();
|
||||
}
|
||||
|
||||
@@ -69,6 +69,18 @@ public class FlipperObject {
|
||||
return new FlipperArray((JSONArray) o);
|
||||
}
|
||||
|
||||
public Object get(String name) {
|
||||
final Object o = mJson.opt(name);
|
||||
|
||||
if (o instanceof JSONObject) {
|
||||
return new FlipperObject((JSONObject) o);
|
||||
} else if (o instanceof JSONArray) {
|
||||
return new FlipperArray((JSONArray) o);
|
||||
} else {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(String name) {
|
||||
return mJson.has(name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user